Results 1 to 2 of 2

Thread: Differences between XHTML and PHP

  1. #1
    Join Date
    May 2008
    Posts
    25

    Differences between XHTML and PHP

    We have seen that XHTML does that create static pages. PHP can get in XHTML code to make it dynamic! See the code of a basic XHTML page that displays "Hello" and the same page in PHP (PHP page must carry the extension. Php for the server to know that this page will be parsed by PHP before to be sent, otherwise you will have the PHP source code that is displayed to visitors, which could be unfortunate, especially if you set passwords!

    Here are the basics of our code XHTML page:

    Code:
    <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "eng" lang= "eng" > 
    <head > 
    <title> Here the title of your page </title> 
    <meta http-equiv= "Content-Type" content= "text/html; charset=iso-8859-1" /> 
    <link rel= "stylesheet" href= "style.css" media= "screen" type= "text/css" /> 
    </head> 
    <body> 
    Hello!
    </body> 
    </html>
    We will now turn this page in PHP, we will use to display text function (which is not really one, but I will not complicate the task) echo (). This feature allows you to display text, we will see how to use it in detail later in the PHP.

    Code:
    <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "fr" lang= "fr" > 
    <head > 
    <title>Here the title of your page </title> 
    <meta http-equiv= "Content-Type" content= "text/html; charset=iso-8859-1" /> 
    <link rel= "stylesheet" href= "style.css" media= "screen" type= "text/css" /> 
    </head> 
    <body> 
    <?php echo ' Hello! ' ; ?> 
    </body> 
    </html>
    It notes that the PHP code in HTML (remember to give your page an extension. Php). At first glance, it does not have many differences, and one may wonder about the usefulness of such a code. For now, the usefulness of such a code is zero. Why? because use PHP to generate static content (here, your page will display all the time Hello!) is unnecessary because it creates a loss of performance (the server needs to process the PHP page before sending it, unlike a page (X) HTML). But patience! PHP is not limited to displaying text (and fortunately), first begin with the basics and deepen then

    We have just seen an example of PHP code embedded in XHTML code, but PHP may well be part of a file without XHTML around. Never forget that PHP can generate text (or pictures) that will be sent to your browser. The code generated by PHP XHTML via the echo () is nothing but text. If we take this for example:
    Code:
    <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "fr" lang= "fr" > 
    <head > 
    <title> Here the title of your page </title> 
    <meta http-equiv= "Content-Type" content= "text/html; charset=iso-8859-1" /> 
    <link rel= "stylesheet" href= "style.css" media= "screen" type= "text/css" /> 
    </head> 
    <body> 
    <p> Hello! </p> 
    </body> 
    </html>

  2. #2
    Join Date
    May 2008
    Posts
    25

    Re: Differences between XHTML and PHP

    It can generate the same thing in PHP (there are several ways to do so, it may very well save all the content in

    Code:
    XHTML echo function ()): 
    <html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "fr" lang= "fr" > 
    <head > 
    <title> Here the title of your page </title> 
    <meta http-equiv= "Content-Type" content= "text/html; charset=iso-8859-1" /> 
    <link rel= "stylesheet" href= "style.css" media= "screen" type= "text/css" /> 
    </head> 
    <body> 
    <?php echo '<p> Hello! </p>' ; ?> 
    </body> 
    </html>
    Visitors will absolutely the same page XHTML! Why use PHP then? because through it, you can put much more complex instructions that the server is running (such as reading a file and display the content or display the number of visitors to a page, etc. ...). You can also personalize pages according to such visitors (as I do on this site by posting Hello visitor if you're not connected to the site and replacing it with your name if you are connected). All this is impossible (X) HTML!

Similar Threads

  1. JKsf and xhtml
    By Sargam in forum Software Development
    Replies: 5
    Last Post: 23-07-2010, 06:09 AM
  2. Don't know about the advantages of XHTML
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 01:43 PM
  3. How to Host an XHTML Website with a FTP?
    By hatred in forum Software Development
    Replies: 5
    Last Post: 06-01-2010, 07:49 PM
  4. Difference between dhtml, xhtml and xml
    By Sacchidananda in forum Software Development
    Replies: 3
    Last Post: 16-11-2009, 07:44 AM
  5. How to use List in XHTML
    By Gyan Guru in forum Guides & Tutorials
    Replies: 2
    Last Post: 03-07-2009, 02:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,519,193.86552 seconds with 17 queries