Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2006, 04:12 AM
Authorized User
 
Join Date: Feb 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dimo414 Send a message via Yahoo to dimo414
Default XHTML in .php Files

I've recently tried to convert my website (which is almost entirely .php files) and when I change it, the page fails to load. I create a .html page with the same content (php commands removed, obviously) and the page loads perfectly, and validly.

I assume this is something to do with PHP, and/or php files; or the calling of php commands <?php 'script' ?> in a file declared to be xml, but how to fix that?. Is there any way to run xhtml in php (or vice versa? What do I have to do?

I'm not sure what forum this would go under, so I apologise if I got it wrong...
 
Old February 19th, 2006, 02:54 PM
Authorized User
 
Join Date: Feb 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dimo414 Send a message via Yahoo to dimo414
Default

No one's ever tried running php in xhtml?

 
Old February 21st, 2006, 07:54 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

PHP has nothing to do with X/HTML except that it can be output-ed by PHP. PHP files always've extension .php

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
mediasworks.com project
 
Old February 21st, 2006, 07:58 PM
Authorized User
 
Join Date: Feb 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dimo414 Send a message via Yahoo to dimo414
Default

This is the basic code for an xhtml page, according to the w3c:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Virtual Library</title>
  </head>
  <body>
    <p>Moved to <a href="http://example.org/">example.org</a>.</p>
  </body>
</html>
But when I insert a php command, such as echo:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Virtual Library</title>
  </head>
  <body>
    <p>Moved to <a href="http://example.org/">example.org</a>.</p>
    <?php echo "Hello World"; ?>
  </body>
</html>
The document fails to load.

 
Old February 27th, 2006, 05:44 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

PHP has problem in line: <?xml version="1.0" encoding="UTF-8"?>

I changed it to:
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>

Actually tags of both PHP and XML are same.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
mediasworks.com project





Similar Threads
Thread Thread Starter Forum Replies Last Post
delimited files using PHP richardk PHP How-To 0 July 16th, 2007 11:40 PM
creating thumbnail for pdf files via php pritz PHP How-To 0 March 10th, 2006 04:09 AM
uploading PHP files Adam H-W Beginning PHP 1 January 20th, 2006 02:06 AM
.php files vs .html files pbuongiovanni PHP How-To 2 January 5th, 2006 04:15 AM
XHTML Compliant PHP page Ben Horne Beginning PHP 6 October 27th, 2004 08:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.