Messed Up PHP Opening and Closing Tags


I have uploaded/imported my files via net2ftp. One of them is a html file which contain some PHP code. The problem is when I open that html file in address bar, the page is messed up. Then I looked at the page source code and found that my PHP opening and closing tags are changed…

<?php SOME_PHP_CODE ?>


This makes my PHP code become invalid and treated as a comment. How do I prevent this from happening?

I didn’t have this problem on my previous account which uses old cPanel. I imported my files exactly from my previous account. I didn’t edit them or anything, so the scripts are exactly the same.

Also, I put PHP code inside a textarea to get the content from a txt file, but it won’t display the text in the txt file. Instead, it shows the PHP code itself. Here’s my code:

<?php file_get_contents('notes.txt'); ?>

Any help will be appreciated.


Can a HTML file contain PHP code?


Yes, it can. Like I said earlier, I have no problem on my previous account which uses old cPanel.


I don’t think PHP code can run in a .html file.


I’m pretty sure HTML can run in .php file, not the other way around, unless you have reference code.



I just had to learn how to use .htaccess file. I added these two lines to .htaccess file and it works like a magic.

php_value display_errors 0

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