Skip to content
Advertisement

Are php strings immutable?

Or: Should I optimize my string-operations in PHP? I tried to ask PHP’s manual about it, but I didn’t get any hints to anything.

Advertisement

Answer

PHP already optimises it – variables are assigned using copy-on-write, and objects are passed by reference. In PHP 4 it doesn’t, but nobody should be using PHP 4 for new code anyway.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement