View Full Version : using PHP in xhtml
09-06-2005, 09:50 AM
Hi, I'm converting a website from html with .php extensions on the files to an xhtml 1.0 transitional site.
In the old site there is some php in the html but it doesn’t seem to be working in the new site.
I tried using .php as the file extensions on the new files, but I get an “XML cant read file” error in the browser.
What do I do?
09-06-2005, 12:34 PM
Use full PHP tags "<?php ... ?>" instead of short tags "<? ... ?>" and see if that helps (it's good practice anyway since it will make your code much more portable - not every server will have short tags enabled).
09-07-2005, 04:19 AM
thanks. i have no idea about php... always a simple solution.
09-07-2005, 07:47 AM
Okay ive given putting <?php... instead of <?... but it still does not work. i've checked the file extensions and all that stuff, but i dont have much of an idea about php.. can anyone point me in the right direction here?
As you can see from the code, ive tried a few variations - but nothing.
09-07-2005, 09:15 AM
Your server does not send .html files to the PHP interpreter. That's why you still see the PHP code embedded in the XHTML output. What you need to do is to configure your server to also treat files with the extension .html as PHP files. Seeing that you use Apache, the following line in your http.conf might help:
AddType application/x-httpd-php .php .phtml .html
As a first step, I would make a tiny PHP test page and check that it gets treated correctly by the server. Then I'd switch the extension on your XHTML page. If still some errors appear, they must come from somewhere else.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.