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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
<h1>PHP</h1>
<p>To use this language, use the class "language-php".</p>
<h2>Comments</h2>
<pre><code>// Single line comment
/* Multi-line
comment */</code></pre>
<h2>Strings</h2>
<pre><code>'foo \'bar\' baz'
"foo \"bar\" baz"</code></pre>
<h2>Variables</h2>
<pre><code>$some_var = 5;
$otherVar = "Some text";
$null = null;
$false = false;</code></pre>
<h2>Functions</h2>
<pre><code>$json = json_encode($my_object);
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);</code></pre>
<h2>Constants</h2>
<pre><code>define('MAXSIZE', 42);
echo MAXSIZE;
json_decode($json, false, 512, JSON_BIGINT_AS_STRING)</code></pre>
<h2>PHP 5.3+ support</h2>
<pre><code>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;
}
}</code></pre>
<h2>PHP embedded in HTML</h2>
<pre><code><div class="<?php echo $a ? 'foo' : 'bar'; ?>">
<?php if($var < 42) {
echo "Something";
} else {
echo "Something else";
} ?>
</div></code></pre>
<h2>Known failures</h2>
<p>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.
</p>
<h3>Comment-like substrings</h3>
<pre><code>"foo /* bar */ baz"; "foo // bar";</code></pre>
<h3>A less-than sign and a greater-than sign on the same line</h3>
<pre><code>if($a < $b && $b > $c) {}</code></pre>