Messed Up PHP Opening and Closing Tags


#1

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…
from:

<?php SOME_PHP_CODE ?>

to:
<–?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.


#2

Can a HTML file contain PHP code?


#3

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


#4

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


#5

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


#6

Solved!

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


#7