note 105751 added to function.printf
| From: | admin at torntech dot com | Date: | Mon, 12 Sep 2011 15:34:06 +0000 |
| Subject: | note 105751 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183110@lists.php.net to get a copy of this message | ||
Normal concatenation is slightly faster than printf for simple combination of strings.
Example:
<?php
$var = "World";
print("Hello $var"); //Faster
printf("Hello %s", $var); //Slower
?>
Tested against 6 for..loops of 100x loops (3 of each) using PHP 5.3.8.
The very first print or echo in the script is always the slowest regardless of type, I assume due to
the application propagating functionality into memory.
Regardless, printf was always ~30 µs slower than normal concatenation in all 3 loop tests.
----
Server IP: 69.147.83.197
Probable Submitter: 173.8.63.13
----
Manual Page -- http://www.php.net/manual/en/function.printf.php
Edit -- https://master.php.net/note/edit/105751
Del: integrated -- https://master.php.net/note/delete/105751/integrated
Del: useless -- https://master.php.net/note/delete/105751/useless
Del: bad code -- https://master.php.net/note/delete/105751/bad+code
Del: spam -- https://master.php.net/note/delete/105751/spam
Del: non-english -- https://master.php.net/note/delete/105751/non-english
Del: in docs -- https://master.php.net/note/delete/105751/in+docs
Del: other reasons-- https://master.php.net/note/delete/105751
Reject -- https://master.php.net/note/reject/105751
Search -- https://master.php.net/manage/user-notes.php