Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-11-2008
JTD JTD is offline
Member
 
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>
Reply With Quote
  #2  
Old 22-11-2008
JTD JTD is offline
Member
 
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!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 12:24 AM.