PHP Performance : Copy vs. Reference

后端 未结 6 1447
南旧
南旧 2021-01-18 02:26

Hey there. Today I wrote a small benchmark script to compare performance of copying variables vs. creating references to them. I was expecting, that creating references to l

6条回答
  •  爱一瞬间的悲伤
    2021-01-18 03:04

    1. In recursiveReference() function you call recursiveCopy() function. It it what you really intended to do?
    2. You do nothing with $foo variable - probably it was supposed to be used in further method call?
    3. Passing variable by reference should generally save stack memory in case of passing large objects.

提交回复
热议问题