diff options
Diffstat (limited to 'php.html.markdown')
-rw-r--r-- | php.html.markdown | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/php.html.markdown b/php.html.markdown index 083574ee..0caa07b6 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -59,6 +59,9 @@ $float = 1.234; $float = 1.2e3; $float = 7E-10; +// Delete variable +unset($int1) + // Arithmetic $sum = 1 + 1; // 2 $difference = 2 - 1; // 1 @@ -136,6 +139,11 @@ echo $associative['One']; // prints 1 $array = ['One', 'Two', 'Three']; echo $array[0]; // => "One" +// Add an element to the end of an array +$array[] = 'Four'; + +// Remove element from array +unset($array[3]); /******************************** * Output @@ -176,6 +184,11 @@ $y = 0; echo $x; // => 2 echo $z; // => 0 +// Dumps type and value of variable to stdout +var_dump($z); // prints int(0) + +// Prints variable to stdout in human-readable format +print_r($array); // prints: Array ( [0] => One [1] => Two [2] => Three ) /******************************** * Logic @@ -463,10 +476,16 @@ class MyClass print 'MyClass'; } + //final keyword would make a function unoverridable final function youCannotOverrideMe() { } +/* +Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. +A property declared as static can not be accessed with an instantiated class object (though a static method can). +*/ + public static function myStaticMethod() { print 'I am static'; |