Debian Codegraph @

examples/prism-php.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>// Single line comment
3 /* Multi-line
4 comment */
5 # Shell-like comment</code></pre>
6
7 <h2>Strings</h2>
8 <pre><code>'foo \'bar\' baz'
9 "foo \"bar\" baz"
10 "a string # containing an hash"
11 $foo = &lt;&lt;&lt;FOO
12 Heredoc strings are supported too!
13 FOO;
14 $bar = &lt;&lt;&lt;'BAR'
15 And also Nowdoc strings
16 BAR;</code></pre>
17
18 <h2>Variables</h2>
19 <pre><code>$some_var = 5;
20 $otherVar = "Some text";
21 $null = null;
22 $false = false;</code></pre>
23
24 <h2>Functions</h2>
25 <pre><code>$json = json_encode($my_object);
26 $array1 = array("a" => "green", "red", "blue", "red");
27 $array2 = array("b" => "green", "yellow", "red");
28 $result = array_diff($array1, $array2);</code></pre>
29
30 <h2>Constants</h2>
31 <pre><code>define('MAXSIZE', 42);
32 echo MAXSIZE;
33 json_decode($json, false, 512, JSON_BIGINT_AS_STRING)</code></pre>
34
35 <h2>PHP 5.3+ support</h2>
36 <pre><code>namespace my\name;
37 $c = new \my\name\MyClass;
38 $arr = [1,2,3];
39 trait ezcReflectionReturnInfo {
40 function getReturnType() { /*1*/ }
41 function getReturnDescription() { /*2*/ }
42 }
43 function gen_one_to_three() {
44 for ($i = 1; $i &lt;= 3; $i++) {
45 // Note that $i is preserved between yields.
46 yield $i;
47 }
48 }</code></pre>
49
50 <h2>PHP embedded in HTML</h2>
51 <pre><code>&lt;div class="&lt;?php echo $a ? 'foo' : 'bar'; ?>">
52 &lt;?php if($var &lt; 42) {
53 echo "Something";
54 } else {
55 echo "Something else";
56 } ?>
57 &lt;/div></code></pre>
58
59 <h2>String interpolation</h2>
60 <pre><code>$str = "This is $great!";
61 $foobar = "Another example: {${$foo->bar()}}";
62 $a = &lt;&lt;&lt;FOO
63 Hello $world!
64 FOO;
65 $b = &lt;&lt;&lt;"FOOBAR"
66 Interpolation inside Heredoc strings {$obj->values[3]->name}
67 FOOBAR;</code></pre>