Advanced
PHP
Q75 / 100
What is PHP's copy-on-write mechanism for arrays?
Correct! Well done.
Incorrect.
The correct answer is B) Arrays share a single zval structure until one is modified, at which point PHP copies the array (lazy duplication)
B
Correct Answer
Arrays share a single zval structure until one is modified, at which point PHP copies the array (lazy duplication)
Explanation
$b = $a copies the reference count. When $b is modified, PHP separates them (copy-on-write). This avoids expensive copies when arrays are only read.
Progress
75/100