svn: /phpdoc/en/trunk/reference/strings/functions/ echo.xml

From: Date: Fri, 18 Dec 2015 22:18:56 +0000
Subject: svn: /phpdoc/en/trunk/reference/strings/functions/ echo.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13921@lists.php.net to get a copy of this message
tpunt Fri, 18 Dec 2015 22:18:56 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=338312 Log: Resolve doc bug #69013 with additional information Bug: https://bugs.php.net/69013 (Assigned) unclear/incomplete statement in echo documentation Changed paths: U phpdoc/en/trunk/reference/strings/functions/echo.xml Modified: phpdoc/en/trunk/reference/strings/functions/echo.xml =================================================================== --- phpdoc/en/trunk/reference/strings/functions/echo.xml 2015-12-18 21:50:39 UTC (rev 338311) +++ phpdoc/en/trunk/reference/strings/functions/echo.xml 2015-12-18 22:18:56 UTC (rev 338312) @@ -137,6 +137,34 @@ <refsect1 role="notes"> &reftitle.notes; &note.language-construct; + <tip> + <para> + A benefit to passing in multiple arguments over using concatenation in + <function>echo</function> regards the precedence of the period operator in + PHP. If multiple arguments are passed in, then parentheses will not be + required to enforce precedence: + </para> + <programlisting role="php"> +<![CDATA[ +<?php +echo "Sum: ", 1 + 2; +echo "Hello ", isset($name) ? $name : "John Doe", "!"; +]]> + </programlisting> + + <para> + With concatenation, the period operator has a higher precedence than both + the addition and ternary operators, and so parentheses must be used for the + correct behaviour: + </para> + <programlisting role="php"> +<![CDATA[ +<?php +echo 'Sum: ' . (1 + 2); +echo 'Hello ' . (isset($name) ? $name : 'John Doe') . '!'; +]]> + </programlisting> + </tip> </refsect1> <refsect1 role="seealso">

« previous php.doc.cvs (#13921) next »