From ef0601bab5c3f7f57e584594fc34da87cf8cce9c Mon Sep 17 00:00:00 2001 From: Afaq Date: Sun, 25 Aug 2013 11:43:07 -0400 Subject: Updated PHP doc to include print_r() and var_dump() --- php.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 083574ee..1a07777a 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -176,6 +176,11 @@ $y = 0; echo $x; // => 2 echo $z; // => 0 +// Dumps type and value of variable to stdout +var_dumb($z); // prints int(3) + +// Prints variable to stdout in human-readable format +print_r($array); // prints: Array ( [0] => One [1] => Two [2] => Three ) /******************************** * Logic -- cgit v1.2.3 From 7af1a853d474fce4feae2429d5e194649fc59105 Mon Sep 17 00:00:00 2001 From: Afaq Date: Sun, 25 Aug 2013 11:49:49 -0400 Subject: Correction to variable output of var_dump() --- php.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 1a07777a..1cc6d2c5 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -177,7 +177,7 @@ echo $x; // => 2 echo $z; // => 0 // Dumps type and value of variable to stdout -var_dumb($z); // prints int(3) +var_dumb($z); // prints int(0) // Prints variable to stdout in human-readable format print_r($array); // prints: Array ( [0] => One [1] => Two [2] => Three ) -- cgit v1.2.3 From 92e921e8f3a9138bdb94b19a15cb76081cc90689 Mon Sep 17 00:00:00 2001 From: ipscott Date: Thu, 29 Aug 2013 23:50:11 -0500 Subject: Update php.html.markdown added a better description for static functions and properties --- php.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 1cc6d2c5..aa73c547 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -468,10 +468,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'; -- cgit v1.2.3 From 6071e57cd962462e720f33ec7870810cd67ba528 Mon Sep 17 00:00:00 2001 From: afaqurk Date: Sat, 31 Aug 2013 23:29:51 -0400 Subject: spelling error on php function: var_dumb() = var_dump() --- php.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 1cc6d2c5..0ff31dd2 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -177,7 +177,7 @@ echo $x; // => 2 echo $z; // => 0 // Dumps type and value of variable to stdout -var_dumb($z); // prints int(0) +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 ) -- cgit v1.2.3 From ba17d5b9877f324fa633c1670c49e6a867ba5734 Mon Sep 17 00:00:00 2001 From: afaqurk Date: Sat, 31 Aug 2013 23:44:15 -0400 Subject: Added unset function to arrays and variables. Added the unset function to show the varying effects of deleting/removing variables and elements of an array. --- php.html.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 0ff31dd2..19f507ad 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 -- cgit v1.2.3 From 4f0206f5aa373bf477bf88d62df720656d3aca2e Mon Sep 17 00:00:00 2001 From: Matthew Johnston Date: Sun, 8 Sep 2013 15:31:46 -0500 Subject: Fixed line wrapping --- php.html.markdown | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 0caa07b6..1952d833 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -107,7 +107,7 @@ echo 'This string ' . 'is concatenated'; /******************************** * Constants */ - + // A constant is defined by using define() // and can never be changed during runtime! @@ -143,7 +143,7 @@ echo $array[0]; // => "One" $array[] = 'Four'; // Remove element from array -unset($array[3]); +unset($array[3]); /******************************** * Output @@ -455,8 +455,10 @@ class MyClass // Static variables and their visibility public static $publicStaticVar = 'publicStatic'; - private static $privateStaticVar = 'privateStatic'; // Accessible within the class only - protected static $protectedStaticVar = 'protectedStatic'; // Accessible from the class and subclasses + // Accessible within the class only + private static $privateStaticVar = 'privateStatic'; + // Accessible from the class and subclasses + protected static $protectedStaticVar = 'protectedStatic'; // Properties must declare their visibility public $property = 'public'; @@ -476,14 +478,15 @@ class MyClass print 'MyClass'; } - //final keyword would make a function unoverridable + //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). + * 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() @@ -674,10 +677,14 @@ $cls = new SomeOtherNamespace\MyClass(); ## More Information -Visit the [official PHP documentation](http://www.php.net/manual/) for reference and community input. +Visit the [official PHP documentation](http://www.php.net/manual/) for reference +and community input. -If you're interested in up-to-date best practices, visit [PHP The Right Way](http://www.phptherightway.com/). +If you're interested in up-to-date best practices, visit +[PHP The Right Way](http://www.phptherightway.com/). -If you're coming from a language with good package management, check out [Composer](http://getcomposer.org/). +If you're coming from a language with good package management, check out +[Composer](http://getcomposer.org/). -For common standards, visit the PHP Framework Interoperability Group's [PSR standards](https://github.com/php-fig/fig-standards). +For common standards, visit the PHP Framework Interoperability Group's +[PSR standards](https://github.com/php-fig/fig-standards). -- cgit v1.2.3 From a3476993b1d44ea033967f979dfa022f0fd72429 Mon Sep 17 00:00:00 2001 From: Arnel Bucio Date: Sun, 15 Sep 2013 14:15:53 +0800 Subject: Fix typo --- php.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 1952d833..226eefff 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -72,7 +72,7 @@ $quotient = 2 / 1; // 2 $number = 0; $number += 1; // Increment $number by 1 echo $number++; // Prints 1 (increments after evaluation) -echo ++$number; // Prints 3 (increments before evalutation) +echo ++$number; // Prints 3 (increments before evaluation) $number /= $float; // Divide and assign the quotient to $number // Strings should be enclosed in single quotes; -- cgit v1.2.3 From a72bcacba5ee50061099a136f035f65989124665 Mon Sep 17 00:00:00 2001 From: Raul Brito Date: Sat, 9 Nov 2013 19:29:14 +0100 Subject: fix typo --- php.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 226eefff..c3317d59 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -11,7 +11,7 @@ This document describes PHP 5+. ```php