What makes a PHP file a PHP file?

What makes a PHP file a PHP file?To create your first php page, you must ensure that the server that you using, is capable to handle such a file extension. You could either get in touch with your server provider or just continue with this tutorial in hope it will work.

The PHP file format

Any file you create to hold PHP must be saved with the .php extension. With out this, your server won’t know how to deal with the page and the data within it will not be ‘parses’ or engaged in the correct manner. There are methods that can force the server to treat any file extension as a PHP or any other format. This will involve the use of an .htaccess file or a Header function. These methods are not covered in the tutorial.

Getting your .php file ready to parse PHP

Now that you have created your PHP file, you will need to make a distinction between standard HTML, CSS or JavaScript by ‘tagging’ the portions of the page that will need to be ‘parsed’.

Example:

<?php ...your code... ?>

Trying it out

Add the following to your php file and copy it over to the server.

<?php
 echo "Hello <b>world!</b>";
?>

The above php will echo¬†out (print on screen) the “Hello world!“.

Leave a Reply

Your email address will not be published. Required fields are marked *