PHP Tutorials

PHP Basics

This tutorial demonstrates the basic PHP commands every php'er should know...
1
Going to take the dive into PHP eh? Here are the basic commands you need to know.

PHP uses the echo command to to return a string to the browser.
<?php
echo "This will be returned to the browser";
?>

In the example above we used echo to return a string to the browser.
2
One of the most important things in PHP are variables. In PHP you assign a variable with the $ sign.
<?php
$name = "Anwar";
echo "Hello there $name";
?>

As you can see we used a variable in the example above, we assigned the value Anwar to the variable name, so the browser would now show Hello there Anwar.
3
PHP is also very suited for including files into web-pages:
<?php
include "menu.php";
?>

In the above example we used the include command to include menu.php into our website. The browser will show all the contents of menu.php on our website.

The include feature really comes in handy when you have 30 pages with the same navigation links. You could just include menu.php on all of the web-pages and if you ever need to adjust a link in the navigation you would only have to adjust menu.php, instead of 30 separate web-pages.
This tutorial was by Pixelshade, brought to you by Robouk, please post any questions in the forum. Thank you.
« BACK TO TUTORIALS