From 7458e15cd208982f12ae3a8d04261aaaf8332044 Mon Sep 17 00:00:00 2001 From: tleb Date: Thu, 14 May 2015 21:30:15 +0000 Subject: add ; to php/en --- 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 039288a0..2d4565e0 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -60,7 +60,7 @@ $float = 1.2e3; $float = 7E-10; // Delete variable -unset($int1) +unset($int1); // Arithmetic $sum = 1 + 1; // 2 -- cgit v1.2.3 From 222cfcd15c7539fd4d2340e5e70cbf3f6b6e087b Mon Sep 17 00:00:00 2001 From: Jonathan Klein Date: Thu, 1 Oct 2015 07:37:05 -0400 Subject: All class constants can be accessed statically --- php.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 2d4565e0..5cc6a785 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -495,7 +495,9 @@ class MyClass } } +// Class constants can always be accessed statically echo MyClass::MY_CONST; // Outputs 'value'; + echo MyClass::$staticVar; // Outputs 'static'; MyClass::myStaticMethod(); // Outputs 'I am static'; -- cgit v1.2.3 From 087d0619481c4812cae387a4704e9ff91b935ea5 Mon Sep 17 00:00:00 2001 From: Luqi Pan Date: Thu, 1 Oct 2015 16:42:51 -0700 Subject: Aligned the comment block --- 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 2d4565e0..52ea2a95 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -487,7 +487,7 @@ class MyClass * 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() { -- cgit v1.2.3 From 0ad95b119d1f0135bf3a9fd55cebf24d63692c11 Mon Sep 17 00:00:00 2001 From: Michele Orselli Date: Fri, 2 Oct 2015 18:24:45 +0200 Subject: adds some new php operators --- php.html.markdown | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 52ea2a95..53be5391 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -215,6 +215,14 @@ assert($a !== $d); assert(1 === '1'); assert(1 !== '1'); +// spaceship operator since PHP 7 +$a = 100; +$b = 1000; + +echo $a <=> $a; // 0 since they are equal +echo $a <=> $b; // -1 since $a < $b +echo $b <=> $a; // 1 since $b > $a + // Variables can be converted between types, depending on their usage. $integer = 1; @@ -264,6 +272,18 @@ if (false) { // ternary operator print (false ? 'Does not get printed' : 'Does'); +// ternary shortcut operator since PHP 5.3 +// equivalent of "$x ? $x : 'Does'"" +$x = false; +print($x ?: 'Does'); + +// null coalesce operator since php 7 +$a = null; +$b = 'Does print'; +echo $a ?? 'a is not set'; // prints 'a is not set' +echo $b ?? 'b is not set'; // prints 'Does print' + + $x = 0; if ($x === '0') { print 'Does not print'; -- cgit v1.2.3 From fb43ef2942f29ece285be3e8944c91bde6306095 Mon Sep 17 00:00:00 2001 From: Dhwani Shah Date: Fri, 2 Oct 2015 14:12:15 -0500 Subject: Added example of when string concatenation can also be helpful with combination of strings with html tags as this is important to understand when templating say output code from a database transaction. --- php.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 3fcce264..86fb14e5 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -102,6 +102,8 @@ END; // String concatenation is done with . echo 'This string ' . 'is concatenated'; +// Strings concatenation can also be combined with html elements +echo 'This string is' . '' . 'bold with strong tags ' . '.' /******************************** -- cgit v1.2.3 From 63793af2e955f8a8abe698c4a70809cfbff63452 Mon Sep 17 00:00:00 2001 From: Dhwani Shah Date: Fri, 2 Oct 2015 14:54:09 -0500 Subject: Added section on how to declare and initialize both single varible and multiple varibles with the same value. Important concept for large structured programs. Seperated this a little bit. --- php.html.markdown | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 86fb14e5..1c2204fd 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -101,9 +101,7 @@ $sgl_quotes END; // String concatenation is done with . -echo 'This string ' . 'is concatenated'; -// Strings concatenation can also be combined with html elements -echo 'This string is' . '' . 'bold with strong tags ' . '.' +echo 'This string ' . 'is concatenated'; /******************************** -- cgit v1.2.3 From 4e139ae2f528a08eb47427ea790bd176092e1bf0 Mon Sep 17 00:00:00 2001 From: Dhwani Shah Date: Fri, 2 Oct 2015 14:57:39 -0500 Subject: unneeded change fixed --- php.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 1c2204fd..d4131992 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -101,7 +101,7 @@ $sgl_quotes END; // String concatenation is done with . -echo 'This string ' . 'is concatenated'; +echo 'This string ' . 'is concatenated'; /******************************** @@ -689,4 +689,4 @@ 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). +[PSR standards](https://github.com/php-fig/fig-standards). \ No newline at end of file -- cgit v1.2.3 From 0904a24f30de1f0311aff17116c0c9e45a5f2772 Mon Sep 17 00:00:00 2001 From: Gayan Date: Wed, 7 Oct 2015 15:12:31 +0800 Subject: Adding exceptions and error handling --- php.html.markdown | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 93066284..80e689b7 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -693,7 +693,37 @@ use My\Namespace as SomeOtherNamespace; $cls = new SomeOtherNamespace\MyClass(); -*/ +// Simple error handling can be done with try catch block + +try { + // Do something +catch ( Exception $e) { + // Handle exception +} + +// When using try catch blocks in a namespaced enviroment use the following + +try { + // Do something +catch (\Exception $e) { + // Handle exception +} + +// Custom exceptions + +class MyException extends Exception {} + +try { + + $condition = true; + + if ($condition) { + throw new MyException('Something just happend'); + } + +} catch (MyException $e) { + // Handle my exception +} ``` @@ -709,4 +739,4 @@ 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). \ No newline at end of file +[PSR standards](https://github.com/php-fig/fig-standards). -- cgit v1.2.3 From a03b4003907e54da8c47c6aabe93c95f958b4f4d Mon Sep 17 00:00:00 2001 From: Gayan Date: Wed, 7 Oct 2015 15:13:17 +0800 Subject: Update php.html.markdown --- php.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 80e689b7..2de0d3fa 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -697,7 +697,7 @@ $cls = new SomeOtherNamespace\MyClass(); try { // Do something -catch ( Exception $e) { +} catch ( Exception $e) { // Handle exception } @@ -705,7 +705,7 @@ catch ( Exception $e) { try { // Do something -catch (\Exception $e) { +} catch (\Exception $e) { // Handle exception } -- cgit v1.2.3 From ddb3c9eab5f12a0942c9aab61a679d58043a483b Mon Sep 17 00:00:00 2001 From: Gayan Date: Wed, 7 Oct 2015 16:01:09 +0800 Subject: Update php.html.markdown --- 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 2de0d3fa..7c796652 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -693,6 +693,11 @@ use My\Namespace as SomeOtherNamespace; $cls = new SomeOtherNamespace\MyClass(); +/********************** +* Error Handling +* +*/ + // Simple error handling can be done with try catch block try { -- cgit v1.2.3 From 960ee4a1856db8eadb96277bb2422edfa8f2a81c Mon Sep 17 00:00:00 2001 From: Gabriel Halley Date: Wed, 7 Oct 2015 23:11:24 -0400 Subject: removing whitespace all over --- 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 93066284..2b1fe1dc 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -515,7 +515,7 @@ class MyClass } } -// Class constants can always be accessed statically +// Class constants can always be accessed statically echo MyClass::MY_CONST; // Outputs 'value'; echo MyClass::$staticVar; // Outputs 'static'; -- cgit v1.2.3 From 3777d8a0597925ac15fe1405cd723f4a613794ae Mon Sep 17 00:00:00 2001 From: Greg Barendt Date: Thu, 15 Oct 2015 16:28:38 -0400 Subject: Remove an extraneous space --- 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 39ec5aef..f6f965fb 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -702,7 +702,7 @@ $cls = new SomeOtherNamespace\MyClass(); try { // Do something -} catch ( Exception $e) { +} catch (Exception $e) { // Handle exception } -- cgit v1.2.3 From 6c14f507c24524de4815cac05b55bf9a56e7cd06 Mon Sep 17 00:00:00 2001 From: Brett Taylor Date: Fri, 16 Oct 2015 12:04:17 +1300 Subject: Adds late static binding to PHP reference --- php.html.markdown | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 39ec5aef..e64f7bfe 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -693,6 +693,43 @@ use My\Namespace as SomeOtherNamespace; $cls = new SomeOtherNamespace\MyClass(); + +/********************** +* Late Static Binding +* +* / + +class ParentClass { + public static function who() { + echo "I'm a " . __CLASS__ . "\n"; + } + public static function test() { + // self references the class the method is defined within + self::who(); + // static references the class the method was invoked on + static::who(); + } +} + +ParentClass::test(); +/* +I'm a ParentClass +I'm a ParentClass +*/ + +class ChildClass extends ParentClass { + public static function who() { + echo "But I'm " . __CLASS__ . "\n"; + } +} + +ChildClass::test(); +/* +I'm a ParentClass +But I'm ChildClass +*/ + + /********************** * Error Handling * @@ -708,9 +745,9 @@ try { // When using try catch blocks in a namespaced enviroment use the following -try { +try { // Do something -} catch (\Exception $e) { +} catch (\Exception $e) { // Handle exception } @@ -719,13 +756,13 @@ try { class MyException extends Exception {} try { - - $condition = true; - + + $condition = true; + if ($condition) { throw new MyException('Something just happend'); } - + } catch (MyException $e) { // Handle my exception } -- cgit v1.2.3 From 3b554a7e13d9aea591b2e5745687850d6d50da02 Mon Sep 17 00:00:00 2001 From: Akshay Kalose Date: Fri, 16 Oct 2015 20:11:37 -0400 Subject: Update PHP with Additional Information --- php.html.markdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 39ec5aef..9a6ddbbb 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -12,7 +12,7 @@ This document describes PHP 5+. "One" // Add an element to the end of an array $array[] = 'Four'; +// or +array_push($array, 'Five'); // Remove element from array unset($array[3]); -- cgit v1.2.3 From c2b68d138cb881994836040fb10e220f0d4fcc93 Mon Sep 17 00:00:00 2001 From: Akshay Kalose Date: Fri, 16 Oct 2015 20:36:19 -0400 Subject: Add Getting Parameters From Functions in PHP --- php.html.markdown | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 39ec5aef..9d9c5847 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -426,6 +426,21 @@ echo $function_name(1, 2); // => 3 // Useful for programatically determining which function to run. // Or, use call_user_func(callable $callback [, $parameter [, ... ]]); + +// You can get the all the parameters passed to a function +function parameters() { + $numargs = func_num_args(); + if ($numargs > 0) { + echo func_get_arg(0) . ' | '; + } + $args_array = func_get_args(); + foreach ($args_array as $key => $arg) { + echo $key . ' - ' . $arg . ' | '; + } +} + +parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World | + /******************************** * Includes */ -- cgit v1.2.3 From b2f51952f024d2e38f02b2541c22dece09bc23d5 Mon Sep 17 00:00:00 2001 From: Akshay Kalose Date: Fri, 16 Oct 2015 21:19:08 -0400 Subject: Fix Grammar --- 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 9a6ddbbb..5e7eba7f 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -12,7 +12,7 @@ This document describes PHP 5+. Date: Fri, 16 Oct 2015 21:43:47 -0400 Subject: Fix Functions Tabbing --- php.html.markdown | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 9d9c5847..de20f4c9 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -379,7 +379,7 @@ for ($i = 0; $i < 5; $i++) { // Define a function with "function": function my_function () { - return 'Hello'; + return 'Hello'; } echo my_function(); // => "Hello" @@ -388,8 +388,8 @@ echo my_function(); // => "Hello" // number of letters, numbers, or underscores. function add ($x, $y = 1) { // $y is optional and defaults to 1 - $result = $x + $y; - return $result; + $result = $x + $y; + return $result; } echo add(4); // => 5 @@ -400,21 +400,21 @@ echo add(4, 2); // => 6 // Since PHP 5.3 you can declare anonymous functions; $inc = function ($x) { - return $x + 1; + return $x + 1; }; echo $inc(2); // => 3 function foo ($x, $y, $z) { - echo "$x - $y - $z"; + echo "$x - $y - $z"; } // Functions can return functions function bar ($x, $y) { - // Use 'use' to bring in outside variables - return function ($z) use ($x, $y) { - foo($x, $y, $z); - }; + // Use 'use' to bring in outside variables + return function ($z) use ($x, $y) { + foo($x, $y, $z); + }; } $bar = bar('A', 'B'); @@ -429,14 +429,14 @@ echo $function_name(1, 2); // => 3 // You can get the all the parameters passed to a function function parameters() { - $numargs = func_num_args(); - if ($numargs > 0) { - echo func_get_arg(0) . ' | '; - } - $args_array = func_get_args(); - foreach ($args_array as $key => $arg) { - echo $key . ' - ' . $arg . ' | '; - } + $numargs = func_num_args(); + if ($numargs > 0) { + echo func_get_arg(0) . ' | '; + } + $args_array = func_get_args(); + foreach ($args_array as $key => $arg) { + echo $key . ' - ' . $arg . ' | '; + } } parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World | -- cgit v1.2.3 From ed4ac31d97b36866a48faf3b9328c320ba55074f Mon Sep 17 00:00:00 2001 From: Sawyer Charles Date: Sun, 18 Oct 2015 17:46:23 -0500 Subject: Added variable amount of parameters as of php 5.6+ --- php.html.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 5bc2ddce..e7b57b4b 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -445,6 +445,16 @@ function parameters() { parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World | +// Since PHP 5.6 you can get a variable number of arguments +function variable($word, ...$list) { + echo $word . " || "; + foreach ($list as $item) { + echo $item . ' | '; + } +} + +variable("Separate", "Hello", "World") // Separate || Hello | world | + /******************************** * Includes */ -- cgit v1.2.3 From b4c8ff365ee1d633470ced72de5f540744fa921a Mon Sep 17 00:00:00 2001 From: Sawyer Charles Date: Sun, 18 Oct 2015 17:47:42 -0500 Subject: capital letter --- 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 e7b57b4b..71f23871 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -453,7 +453,7 @@ function variable($word, ...$list) { } } -variable("Separate", "Hello", "World") // Separate || Hello | world | +variable("Separate", "Hello", "World") // Separate || Hello | World | /******************************** * Includes -- cgit v1.2.3 From 087dbecb2f25c2d372ed4e007f7641cbc87c0571 Mon Sep 17 00:00:00 2001 From: Tom Duff Date: Sun, 18 Oct 2015 20:21:42 -0400 Subject: Add more examples and explanations Added some clarifying examples to sections on echo(), constants, and cleaned up formatting on others. Added further explanation about the spaceship operator. --- php.html.markdown | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 5bc2ddce..127e601b 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -104,7 +104,8 @@ END; echo 'This string ' . 'is concatenated'; // Strings can be passed in as parameters to echo -echo 'Multiple', 'Parameters', 'Valid'; +echo 'Multiple', 'Parameters', 'Valid'; // Returns 'MultipleParametersValid' + /******************************** * Constants @@ -117,8 +118,10 @@ echo 'Multiple', 'Parameters', 'Valid'; // followed by any number of letters, numbers, or underscores. define("FOO", "something"); -// access to a constant is possible by direct using the choosen name -echo 'This outputs '.FOO; +// access to a constant is possible by calling the choosen name without a $ +echo FOO; // Returns 'something' +echo 'This outputs '.FOO; // Returns 'This ouputs something' + /******************************** @@ -159,9 +162,9 @@ echo('Hello World!'); print('Hello World!'); // The same as echo -// echo is actually a language construct, so you can drop the parentheses. +// echo and print are language constructs too, so you can drop the parentheses echo 'Hello World!'; -print 'Hello World!'; // So is print +print 'Hello World!'; $paragraph = 'paragraph'; @@ -219,7 +222,11 @@ assert($a !== $d); assert(1 === '1'); assert(1 !== '1'); -// spaceship operator since PHP 7 +// 'Spaceship' operator (since PHP 7) +// Returns 0 if values on either side are equal +// Returns 1 if value on the left is greater +// Returns -1 if the value on the right is greater + $a = 100; $b = 1000; -- cgit v1.2.3 From c69ef3115bb900a5b2f716ebd9791a38ca113ab7 Mon Sep 17 00:00:00 2001 From: labrack Date: Thu, 22 Oct 2015 13:06:15 -0400 Subject: [php/en] Un-beef a comment block closing Somebody beefed a closing on the 'Late Static Binding' Comment block, causing the next 18 or so lines to be included in the comment instead of parsed for syntax properly. --- 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 127e601b..403fc41d 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -723,7 +723,7 @@ $cls = new SomeOtherNamespace\MyClass(); /********************** * Late Static Binding * -* / +*/ class ParentClass { public static function who() { -- cgit v1.2.3 From 5afca01bdfb7dab2e6086a63bb80444aae9831cb Mon Sep 17 00:00:00 2001 From: Liam Demafelix Date: Fri, 30 Oct 2015 23:26:49 +0800 Subject: [php/en] Line 159 - echo isn't a function, print() is Line 337 - unneeded semicolon (it's a pre-test loop) --- php.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 0504ced2..7b0cf61c 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -3,6 +3,7 @@ language: PHP contributors: - ["Malcolm Fell", "http://emarref.net/"] - ["Trismegiste", "https://github.com/Trismegiste"] + - [ Liam Demafelix , https://liamdemafelix.com/] filename: learnphp.php --- @@ -156,14 +157,13 @@ unset($array[3]); * Output */ -echo('Hello World!'); +echo 'Hello World!'; // Prints Hello World! to stdout. // Stdout is the web page if running in a browser. print('Hello World!'); // The same as echo -// echo and print are language constructs too, so you can drop the parentheses -echo 'Hello World!'; +// print is a language construct too, so you can drop the parentheses print 'Hello World!'; $paragraph = 'paragraph'; @@ -335,7 +335,7 @@ switch ($x) { $i = 0; while ($i < 5) { echo $i++; -}; // Prints "01234" +} // Prints "01234" echo "\n"; -- cgit v1.2.3 From c23fa3613874bc22b65e5506c374c8f8bf2691d8 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Oct 2015 19:34:51 +0800 Subject: Revert "[php/en]" This reverts commit 5afca01bdfb7dab2e6086a63bb80444aae9831cb. --- php.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'php.html.markdown') diff --git a/php.html.markdown b/php.html.markdown index 7b0cf61c..0504ced2 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -3,7 +3,6 @@ language: PHP contributors: - ["Malcolm Fell", "http://emarref.net/"] - ["Trismegiste", "https://github.com/Trismegiste"] - - [ Liam Demafelix , https://liamdemafelix.com/] filename: learnphp.php --- @@ -157,13 +156,14 @@ unset($array[3]); * Output */ -echo 'Hello World!'; +echo('Hello World!'); // Prints Hello World! to stdout. // Stdout is the web page if running in a browser. print('Hello World!'); // The same as echo -// print is a language construct too, so you can drop the parentheses +// echo and print are language constructs too, so you can drop the parentheses +echo 'Hello World!'; print 'Hello World!'; $paragraph = 'paragraph'; @@ -335,7 +335,7 @@ switch ($x) { $i = 0; while ($i < 5) { echo $i++; -} // Prints "01234" +}; // Prints "01234" echo "\n"; -- cgit v1.2.3