Doc #69013 [Asn->Csd]: unclear/incomplete statement in echo documentation

From: Date: Fri, 18 Dec 2015 22:19:54 +0000
Subject: Doc #69013 [Asn->Csd]: unclear/incomplete statement in echo documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12989@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69013&edit=1 ID: 69013 Updated by: tpunt@php.net Reported by: teo8976 at gmail dot com Summary: unclear/incomplete statement in echo documentation -Status: Assigned +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Assigned To: tpunt Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2015-12-18 22:19:34] tpunt@php.net It may be a micro-optimisation (I haven't personally done an artificial benchmark for it, though :), but the actual benefit to passing in multiple arguments over concatenation actually concerns the precedence of the period operator in PHP. If you'd like to use other operators in the expression (like the ternary operator), then with concatenation, you'll need to enforce precedence using parentheses: echo "Hello " . (isset($name) ? $name : "John Doe") . "!"; Versus: echo "Hello ", isset($name) ? $name : "John Doe", "!"; I've resolved this with commits: https://svn.php.net/viewvc?view=revision&revision=338311 https://svn.php.net/viewvc?view=revision&revision=338312 ------------------------------------------------------------------------ [2015-12-18 22:18:59] tpunt@php.net Automatic comment from SVN on behalf of tpunt Revision: http://svn.php.net/viewvc/?view=revision&revision=338312 Log: Resolve doc bug #69013 with additional information ------------------------------------------------------------------------ [2015-12-18 21:50:42] tpunt@php.net Automatic comment from SVN on behalf of tpunt Revision: http://svn.php.net/viewvc/?view=revision&revision=338311 Log: Resolve doc bug #69013 ------------------------------------------------------------------------ [2015-02-08 02:55:42] teo8976 at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.echo --- """ // Some people prefer passing multiple parameters to echo over concatenation. echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10); echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n"; """ "Some people prefer"? And is or isn't there a reason for that? According to http://www.mdproductions.ca/guides/50-best-practices-to-optimize-php-code-performance the first is more efficient. If that is true, it is of huge importance that it is mentioned ("Some people prefer .... because it's faster") If it's not, then it's worth stating that it is a false myth ("Some people prefer... but it makes no difference") In other words, Either they are equivalent, in which case you should replace "Some people prefer" with "The following are equivalent" or "produce the exact same result", or they are not, in which case the differences or advantages (other than mere taste) of one over the other need to be clarified. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69013&edit=1

« previous php.doc.bugs (#12989) next »