note 41186 added to function.echo
| From: | george at geteducation dot com | Date: | Fri, 02 Apr 2004 03:31:11 +0000 |
| Subject: | note 41186 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67499@lists.php.net to get a copy of this message | ||
Using Single quotes Vs. Double quotes with echo
When we need variable interpolation (substitute the variable with its value) inside a string the
choice of double quotes is obvious over single quotes.
But when there is no varibale interpolation involved, the choice between Single quotes and Double
quotes is influenced by:
A. Performance issues in using single quotes vs double quotes
It might seem that single quote are faster then double quotes since php does not need to parse the
string inside the single quotes to do variable interpolation.
But benchmarks available at
http://www.geteducation.com/enhdocs/php/echo-benchmark.html
show that there is no difference at all.
(if you would like to see other examples in the benchmark send me a email and i will put them there)
Please note that these benchmarks are running on php version > 4.3. There were some lexer
changes in php 4.3 which eqaulized these differences
B. formatting charecters are not translated in single quotes
hence \n inside single quotes wont give you a new line
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41186
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41186&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41186&report=yes
Search -- http://master.php.net/manage/user-notes.php