67 lines
1.6 KiB
Java
67 lines
1.6 KiB
Java
<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> |