1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<?php
/**
* Github Issue: https://github.com/emacs-php/php-mode/issues/66
*
* A large battery of tests to exercise the new cc-mode-based indentation and
* fontification code.
*
* This is mainly just code copy-pasted from the PHP manual.
*/
// http://www.php.net/manual/en/language.exceptions.php
function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
}
else return 1/$x;
}
try {
echo inverse(5) . "\n";
echo inverse(0) . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// http://www.php.net/manual/en/functions.anonymous.php
$greet = function($name)
{
printf("Hello %s\r\n", $name);
};
$greet('World');
$greet('PHP');
|