PHP presentation examples

note: <br> is a HTML linebreak, // or # starts a comment
First example
<?php
$variable = "Hello World!";
echo $variable."<br>"; //prints out Hello World
?>
output:
Hello World!
Second example
<?php
$namearray = array("George", "Tim", "Struppi");
echo $namearray[1]."<br>"; //prints out Tim
foreach($namearray as $index => $name)
{
$index = $index+1; //add 1 up to dont start with 0
echo $index.". name is ".$name."<br>";
}
?>
output:
Tim
1. name is George
2. name is Tim
3. name is Struppi
custom function
<?php
$Name = "George";
hello($Name);
$Name = "Tim";
hello($Name);
hello("Struppi");
function hello($Name)
{
echo "Hello $Name, how are you?<br>";
}
?>
output:
Hello George, how are you?
Hello Tim, how are you?
Hello Struppi, how are you?