To use this language, use the class "language-php".
// Single line comment
/* Multi-line
comment */
# Shell-like comment
'foo \'bar\' baz'
"foo \"bar\" baz"
"a string # containing an hash"
$some_var = 5;
$otherVar = "Some text";
$null = null;
$false = false;
$json = json_encode($my_object);
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
define('MAXSIZE', 42);
echo MAXSIZE;
json_decode($json, false, 512, JSON_BIGINT_AS_STRING)
namespace my\name;
$c = new \my\name\MyClass;
$arr = [1,2,3];
trait ezcReflectionReturnInfo {
function getReturnType() { /*1*/ }
function getReturnDescription() { /*2*/ }
}
function gen_one_to_three() {
for ($i = 1; $i <= 3; $i++) {
// Note that $i is preserved between yields.
yield $i;
}
}
<div class="<?php echo $a ? 'foo' : 'bar'; ?>">
<?php if($var < 42) {
echo "Something";
} else {
echo "Something else";
} ?>
</div>
There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. However, Prism dares to be open and honest about them. If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
"foo // bar";
# Shell-like comment "with quotes" inside
# Shell-like comment 'with quotes' inside
if($a < $b && $b > $c) {}