From 789cc2c2a7f77585792bd32ac5e06737891609b1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 29 Jun 2013 20:38:22 -0700 Subject: Merged in (and formatted line lenghts for) emarref's require commit --- php.html.markdown | 63 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 10 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 7db50136..20923548 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -10,7 +10,8 @@ This document describes PHP 5+. ```php tags -// If your php file only contains PHP code, it is best practise to omit the php closing tag. +// If your php file only contains PHP code, it is best practise +// to omit the php closing tag. // Two forward slashes start a one-line comment. @@ -171,8 +172,8 @@ $d = '1'; // These comparisons will always be true, even if the types aren't the same. assert($a == $b); // equality -assert($b != $a); // inequality -assert($a <> $b); // alternative inequality +assert($c != $a); // inequality +assert($c <> $a); // alternative inequality assert($a < $c); assert($c > $b); assert($a <= $b); @@ -254,7 +255,8 @@ This is displayed otherwise. switch ($x) { case '0': print 'Switch does type coercion'; - break; // You must include a break, or you will fall through to cases 'two' and 'three' + break; // You must include a break, or you will fall through + // to cases 'two' and 'three' case 'two': case 'three': // Do something if $variable is either 'two' or 'three' @@ -367,7 +369,45 @@ $bar('C'); // Prints "A - B - C" $function_name = 'add'; echo $function_name(1, 2); // => 3 // Useful for programatically determining which function to run. -// Alternatively, use call_user_func(callable $callback [, mixed $parameter [, mixed $... ]]); +// Or, use call_user_func(callable $callback [, $parameter [, ... ]]); + +/******************************** + * Includes + */ + +/* +``` +```php + -$my_class = new MyClass('An instance property'); // The parentheses are optional if not passing in an argument. echo $my_class->property; // => "public" echo $my_class->instanceProp; // => "An instance property" $my_class->myMethod(); // => "MyClass" @@ -425,7 +468,7 @@ class MyOtherClass extends MyClass { function printProtectedProperty() { - echo $this->protProp; + echo $this->prot; } // Override a method @@ -516,7 +559,7 @@ class SomeOtherClass implements InterfaceOne, InterfaceTwo * Traits */ -// Traits are available since PHP 5.4.0 and are declared using the trait keyword. +// Traits are available from PHP 5.4.0 and are declared using "trait" trait MyTrait { -- cgit v1.2.3