A couple questions about PHP

The geek forum. PHP, Perl, HTML, hardware questions etc.. it's all in here. Got a techie question? We'll sort you out. Ask your questions or post a link to your own site here!

A couple questions about PHP

Postby Mr. Rogers » Sun Sep 11, 2005 11:36 am

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?
User avatar
Mr. Rogers
 
Posts: 1512
Joined: Sat Sep 06, 2003 10:23 pm
Location: Chicago, IL

Postby Kaligraphic » Sun Sep 11, 2005 12:29 pm

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.
The cake used to be a lie like you, but then it took a portal to the deception core.
User avatar
Kaligraphic
 
Posts: 2002
Joined: Wed Jul 21, 2004 12:00 pm
Location: The catbox of DOOM!


Return to Computing and Links

Who is online

Users browsing this forum: No registered users and 59 guests