<?php
// This is a single-line comment
# You can also make single-line comments like this
?>
<?php
/*
This comment block spans
over multiple
lines
*/
?>
<?php
for($index = 0; $index < 5; $index ++)
{
echo "Current loop counter ".$index.".\n";
}
?>
/*
Output:
Current loop counter 0.
Current loop counter 1.
Current loop counter 2.
Current loop counter 3.
Current loop counter 4.
*/
<?php
$index = 10;
while ($index >= 0)
{
echo "The index is ".$index.".\n";
$index--;
}
?>
/*
Output:
The index is 10.
The index is 9.
The index is 8.
The index is 7.
The index is 6.
The index is 5.
The index is 4.
The index is 3.
The index is 2.
The index is 1.
The index is 0.
*/
<?php
echo date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
echo date("m.d.y"); // 03.10.01
echo date("j, n, Y"); // 10, 3, 2001
echo date("Ymd"); // 20010310
echo date('h-i-s, j-m-y, it is w Day z '); // 05-16-17, 10-03-01, 1631 1618 6 Fripm01
echo date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day.
echo date("D M j G:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001
echo date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month
echo date("H:i:s"); // 17:16:17
?>