开发者

Webpage won't parse PHP code

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 do开发者_如何学Goesn't parse on this page. JS works fine. Any ideas? It's a simple .html page.


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

AddType application/x-httpd-php .php .html


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.


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).


Your page has to be a .php page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜