3

I'm trying to add some of my own PHP to a nearly-unreadable template file on a forum system. I know it all works perfectly as far as the server config, etc. goes, but PHP simply doesn't parse on this page. JS works fine. Any ideas? It's a simple .html page.

1
  • 2
    another guess into the blue: forum doesn't pipe those template files through php. Commented Nov 30, 2010 at 7:23

4 Answers 4

4

Try adding this to your .htaccess (or creating a new one in the appropriate directory):

AddType application/x-httpd-php .php .html
Sign up to request clarification or add additional context in comments.

5 Comments

Good idea but doesn't work. I think this is on the right track though.
Maybe .htaccess are disabled from your httpd.conf. Look for the line AllowOverride None and change it to AllowOverride All, and see: httpd.apache.org/docs/1.3/howto/htaccess.html
.htaccess is enabled, I've made changes to it before that have shown up.
@Andrei Korchagin - You have to restart the server.
@Andrei Korchagin - then try adding the RemoveHandler directive as per @Pradeep's answer.
3

Is it possible that the template file is being read into a variable rather than being included or required? Eg. it's loaded using file_get_contents or something similar?

If this is the case you may need to eval() the template code after it has been loaded as file_get_contents does not parse php code, it just loads the text as it is into a variable. It's a very ugly solution but it may work for you. Please be careful if you do this as it does open up a whole can of security issue worms.

Comments

2

A lot of template systems use their own coding syntax. If this is the case it will not be possible to include PHP code in your template without opening up a lot of security holes.

Try to learn the specific templating language used, or find out where you should put the code without changing the template file (there may be a controller or plugin system built for such stuff).

Comments

0

Your page has to be a .php page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.