Home | Store | osCommerce Tutorials

What is PHP

You may consider PHP as part of the HTML document.

PHP files should be saved with the .php file extension (e.g. myfile.php, test.php)

A block of PHP code starts with "<?php" and ends with "?>" and can be placed anywhere in the HTML document.

A block of PHP code should looks like:

<?php

//PHP commands here

?>

A typical example of PHP codes placed in HTML document should look like:

<html>
<head>
<title>PHP Tutorial</title>
</head>
<body>

<h1>Typical PHP Example</h1>

<?php

//PHP commands here
echo "Hello World";

?>

</body>
</html>

The output of the above typical PHP example should look like:

Typical PHP Example

Hello World

Comments

In PHP codes, all comments are preceded by //. Comments will be ignored by computer. Comments simply allow people to understand your codes as well provide easy maintenance purpose for programers.

Remember that every PHP command ends with a semicolon (;).