PHP Tutorial

? ?

How to setup a PHP file

To tell to the server that our code from within a file represents PHP code, we need to include the code between <?php and ?>.


// ... here we put the PHP code


A PHP file must have the .php extension at the ending of it's name, having the full name like "contact_us.php" or "homepage.php" .

What are the delimiters for the PHP scripts?


When writing PHP code we may want to add some explanation lines or just add some short descriptions. This is a thing that it's quite encouraged, this way you or somebody else will understand better and easier the purpose of your code.

The server will not use the comments, it will treat them as they don't exist among the code.

To add a single line of comment use // at the beginning of the line.


//This is a single line of comment

If you need to add longer comments you can use the delimeters /*, that marks the start, and */ that marks the end of the comment.


/* This is the first line
here is the second line

and here is the last line

How do you add comments in PHP?