Page 1 of 1

A couple questions about PHP

PostPosted: Sun Sep 11, 2005 11:36 am
by Mr. Rogers
I've been learning PHP and I have a few questions.

1) If I have any PHP in a file, does the file have to be saved as PHP? Can I put PHP in an HTML file and save it as an HTML and it will still work?

2) Also, when I put all the XHTML doctypes in my file, and then put PHP in it, it gives me a parse error. Does XHTML not like PHP?

PostPosted: Sun Sep 11, 2005 12:29 pm
by Kaligraphic
You can save files with php in them as html, but the php will only work if your web server runs .html files through php - so it won't work by default, but you can change it to work. It's usually best to use the .php extension, though, because just about any web server with php enabled will process them correctly. If you really want to, though, we can help you configure your web server to run php code in .html files.

As for the xhtml doctypes, I've used them with no problems - php doesn't really care what's outside of your php blocks. Check for extra or missing <? <?php or ?> markers, and make sure you're not declaring the doctype inside the php block.