LLLLLLL Posted July 27, 2016 Share Posted July 27, 2016 This is not the common "I don't know how to set Apache to handle PHP in an HTML file" type of issue. That works. AddHandler application/x-httpd-php5 .html I don't usually configure things like this, but I'm working with an existing site and I don't really want to make a change to URLs here. (If all else fails I'll just add a rewrite in .htaccess.) Here are two examples of what's happening: I have some files that are PHP, and they include HTML files. The HTML partial files sometimes have PHP code. That code works. If I simply try to access somefile.html, and that file includes only PHP code, the raw PHP code will be displayed, instead of being executed as code. Why would that first bullet point be true if that second one is false? Again, I wouldn't have structured things how they are structured now, if starting from scratch. I'll probably do something a little bit different but I would like to know, as general knowledge, why the current setup would fail. Does it matter that in one example a PHP code is being called first, where as the other example calls a .html file directly (as opposed to being included)? Quote Link to comment https://forums.phpfreaks.com/topic/301648-php-code-in-html-file-just-shows-as-php-sometimes/ Share on other sites More sharing options...
kicken Posted July 27, 2016 Share Posted July 27, 2016 Sounds like it is just a common server-configuration problem. If you have a PHP file includeing other files then those files will be parsed for PHP code regardless of their extension or the server's configuration. That is what the include function does, it includes another file as PHP code. Accessing a .html file directly and having the PHP code not be executed means that your setup is not properly configured to apply PHP to .html files. Go over your configuration again and verify it is correct and being loaded by apache. Quote Link to comment https://forums.phpfreaks.com/topic/301648-php-code-in-html-file-just-shows-as-php-sometimes/#findComment-1535101 Share on other sites More sharing options...
LLLLLLL Posted July 27, 2016 Author Share Posted July 27, 2016 The only Apache setting I know to allow PHP to apply to HTML is AddHandler application/x-httpd-php5 .html That's already there. Quote Link to comment https://forums.phpfreaks.com/topic/301648-php-code-in-html-file-just-shows-as-php-sometimes/#findComment-1535102 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.