JDT

 

FREE Downloads
Articles
Tutorials

 

Introduction to developing web sites using PHP - Part 2


PHP code can be integrated directly into web pages. In order to do this though, you need to change the file extension for the web page to .php. If you leave it as .htm, for example, the web server will not know that the page contains PHP code and will not process the page correctly - it will treat the PHP code as HTML code and try to process it accordingly.

When you request a web page that has an extension of .php, the web server passes the page to a bit of software called a PHP preprocessor. What this does is to go through the page and to process the PHP code correctly. This normally generates some HTML code, which then gets integrated into the web page in place of the PHP code. The page is then passed back to the web server, which then sends the page to the browser.

If you perform a 'view source' on such a web page, you will not see any PHP code as it has been 'turned into' HTML code. This, of course, is just to enable the page to be correctly displayed in the web browser - the version of the page held on the web server still contains PHP code.

Note: If you need to integrate some PHP code into a web page with a .htm (or .html) extension, and you can't change the extension to .php, you can embed the PHP code into a separate file and use an iframe to integrate it into the .htm page. See Embed a PHP Script in an HTML (.htm or .html) Web Page for more information.

Example

Here is a really simple example of how to integrate PHP code into a web page:

<html> <head></head> <body> <?php print "<p>Hello World</p>\n"; ?> </body> </html>


<- Go to Part 1







Go back to PHP Tutorials home page

Go back to Tutorials home page



Earnings Tracker is John Dixon Technology's FREE accounting / bookkeeping software tool.

Aimed at contractors and freelancers, Earnings Tracker enables you to perform bookkeeping and accounting tasks, helping you to keep track of your company's earnings and outgoings.

The software is written in PHP and MySQL and is available to use for FREE online, or as a FREE download.

Earnings Tracker can also be used simply as a dividend, corporation tax, or VAT calculator.

Need free accounting software
 


JDT

Copyright Notice for John Dixon Technology Ltd

Privacy Statement

Terms & Conditions