3 ms·
I could be wrong about the inefficiency, maybe arrays in PHP are implemented as "copy on write". But seeing how PHP is such a mess of a language, I somehow dou
by edtechre 15y ago
I could be wrong about the inefficiency, maybe arrays in PHP are implemented as "copy on write". But seeing how PHP is such a mess of a language, I somehow doubt it...
- pilif 15y agoThey ARE implemented as COW. It's discouraged to use explicit reference passing if you don't want to alter the array as PHP has to do a slight bit more work if you pass a reference. I think copy on write was added in the 5.1 timeframe (around 2005)
- edtechre 15y agoThanks for the info. I do think the default should have been pass by reference though, like with objects since PHP5.
- pilif 15y agoArrays (and everything else) should be objects. That would also solve the pass-by-reference issue and would clean up the global namespace that's littered with array_* functions.
- deleted 15y ago[deleted]
- wvenable 15y agoCopy-on-write has been around a lot longer than 5.1. I'd venture to say PHP 4 but someone will likely reply and say it was even earlier.