PHP Syntax Example
PHP in HTML
<p> <?php echo "Hello World!" ?> </p>
PHP Documentation Links
<?php
// Create a simple array.
$array = array(1, 2, 3, 4, 5);
print_r($array);
// Now delete every item, but leave the array itself intact:
foreach ($array as $i => $value) {
unset($array[$i]);
}
print_r($array);
// Append an item (note that the new key is 5, instead of 0).
$array[] = 6;
print_r($array);
// Re-index:
$array = array_values($array);
$array[] = 7;
print_r($array);
?>
Plain PHP
This mode is designed for plain PHP files, rather than HTML files which contain PHP tags:
Plain PHP supports both short tags <? echo "Foo" ?> and long tags <?php echo "Bar" ?>
It doesn't add formatting to any other data such as HTML tags. If you are using PHP to generate some kind of data, which is not HTML, use this brush. Otherwise, use the html brush and <?php ?> tags.
Alternatively, if you simply want to format PHP code without short or long tags, you can use the php-script brush, which is the core brush responsible for highlighting PHP source code.
Follow Me