Hash :
36a5fa0e
Author :
Date :
2019-06-30T04:19:54
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 67
<h2>Comments</h2>
<pre><code>// Single line comment
/* Multi-line
comment */
# Shell-like comment</code></pre>
<h2>Strings</h2>
<pre><code>'foo \'bar\' baz'
"foo \"bar\" baz"
"a string # containing an hash"
$foo = <<<FOO
Heredoc strings are supported too!
FOO;
$bar = <<<'BAR'
And also Nowdoc strings
BAR;</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>String interpolation</h2>
<pre><code>$str = "This is $great!";
$foobar = "Another example: {${$foo->bar()}}";
$a = <<<FOO
Hello $world!
FOO;
$b = <<<"FOOBAR"
Interpolation inside Heredoc strings {$obj->values[3]->name}
FOOBAR;</code></pre>