
|
View Full Version : XHTML strict and PHP
SarcasticDwarf 03-02-2004, 11:51 PM Assume I have had someone give me a static layout of a XHTML strict (not transitional) page. I want to merge my existing PHP page into that new page. Other than eliminating the deprecated elements like <center></center>, how would I integrate it? Do I just lump all the PHP code into the new document and put it between <?php and ?>?
Rich2k 03-03-2004, 07:14 AM You use PHP with XHTML in exactly the same way as you used PHP with HTML.
PHP is a server side language and thus completely independent from the client side languages.
Burhan 03-04-2004, 09:35 AM One thing though -- if you choose to include the xml declaration with your XHTML page, make sure you echo it with PHP, otherwise (if you have short_tags turned on) the PHP parser will complain about it.
SarcasticDwarf 03-04-2004, 11:31 PM I can't even get
<?php
echo "Hello!";
?>
to work, hmm?
w3needs 03-04-2004, 11:53 PM Well, you can login and see if the server is reading PHP. Then, make up a page where the only thing it should say is hello in the php file. See if the server is viewing php, then if it is parsing php code.
If both are true, look at the html file itself when viewed in your browser. I have had instance where, by using some positioning tags, the debugging messages I was using were not easily seen..maybe this is what is going on.
Other possibilities that I am assuming you have done...
Save the page as a .php or .php4, or whatever extension you have you server set to view php files.
Making sure that your php tagging is accurate, no wrong special characters.
Please post back and let us know if you got it workin or not:)
Later
SarcasticDwarf 03-05-2004, 12:33 AM Maybe my underestanding of XHTML is all wrong. My site is completely PHP accessing a MySQL database. All pages are *.php. I was given a new layout for the site that I really like that is XHTML strict, but the person who made it did not include the PHP stuff. I was assuming that I could add in all the MySQL queries into the *.html file I was given using <?php and ?>. Is my understnading wrong?
Originally posted by pcgamez
Is my understnading wrong?
Yes, if you are saving the file as .html; at least that's what I gathered from your previous post.
When you are using PHP functionality (i.e. MySQL queries) in your page, you have to save the page as .php.
To make your PHP pages XHTML compliant, you'd use XHTML format for whatever HTML-code you embed in the <?php-tag?>. I could be wrong though...
example:
<?php
// stuff
echo "This is a test<br />"; // as opposed to <br>
?>
SarcasticDwarf 03-05-2004, 12:56 AM ah, that explains it then.
*sigh* more work
SarcasticDwarf 03-05-2004, 01:16 AM wait, now would I still leave the DOCTYPE declaration as the first line, and have the second line be <?php
?
You can just:
<?php
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\">\n";
#rest of code ...
?>
Rich2k 03-05-2004, 09:23 AM You may find it useful to use XHTML 1.0 Transitional until you get used to it.
w3needs 03-05-2004, 12:43 PM Yes, get familiar with the presentation coding you are using, and then start implementing your server-side code.
As for that, indeed, you will simply write your query, and then jsut place the strings in the areas of the 'templated' html file, but, you msut save it as a .php, o .php3, or .php4(.php is now the standard).
Good that you found out what was wrong and learned from it!:)
Take care
Brightadmin 03-15-2004, 09:55 AM Hi,
You can embed your xhtml tags in different ways. Please try the ways given below.
--------------------------------------------------------------------------------------
<
echo('<?xml version="1.0" encoding="utf-8"?>');
?>
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
--------------------------------------------------------------------------------------
Or turn off PHP short tags. So <?php foo(bar); ?> is required, and <?xml ... > won't get parsed.
Have a look at www.w3.org and http://validator.w3.org - it validates your work, and checks for errors on your page.
Regards,
Bright:)
robeyh 03-16-2004, 05:40 PM Umm... you do not have to rename all of the files to .php. Just put
AddHandler php-script .html
into either your .htaccess file in that directory or into the root configuration file.
Rich2k 03-16-2004, 06:26 PM Yes but if you have any plain HTML pages that don't contain PHP code you are wasting server resources by doing that.
robeyh 03-16-2004, 06:32 PM yeah, but most servers are under utilized anyway. And the resources it takes to parse for php are minimal to the resources it takes to run php. Not saying that there aren't circumstances where this would be a bad idea. I just don't think this is one of them.
|