note 128199 added to language.operators.string
| From: | gajowy at agzeta dot pl | Date: | Thu, 09 Feb 2023 03:04:03 +0000 |
| Subject: | note 128199 added to language.operators.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220156@lists.php.net to get a copy of this message | ||
It seems unbelievable, but
$str = $str.$something;
is more than 20 times faster than
$str .= $something;
Sometimes it matters. Take the test!
$buf = ''; $buf1 = 'X';
$hr = -hrTime(TRUE);
for( $j=0; $j<100_000; $j++ )
$buf = $buf.$buf1;
$hr += hrTime(TRUE);
$buf = '';
$hr = -hrTime(TRUE);
for( $j=0; $j<100_000; $j++ )
$buf .= $buf1;
$hr += hrTime(TRUE);
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 85.221.144.172)
----
Manual Page -- https://php.net/manual/en/language.operators.string.php
Edit -- https://main.php.net/note/edit/128199
Del: integrated -- https://main.php.net/note/delete/128199/integrated
Del: useless -- https://main.php.net/note/delete/128199/useless
Del: bad code -- https://main.php.net/note/delete/128199/bad+code
Del: spam -- https://main.php.net/note/delete/128199/spam
Del: non-english -- https://main.php.net/note/delete/128199/non-english
Del: in docs -- https://main.php.net/note/delete/128199/in+docs
Del: other reasons-- https://main.php.net/note/delete/128199
Reject -- https://main.php.net/note/reject/128199
Search -- https://main.php.net/manage/user-notes.php