All pastes #1091266 Raw Edit

rewbs

public php v1 · immutable
#1091266 ·published 2008-08-02 22:12 UTC
rendered paste body
<?php$ao = new ArrayObject();$swapIn = array();$cowRef = $swapIn; // create a copy-on-write ref to $swapIn$ao->exchangeArray($swapIn);$ao['a'] = 'This affects $swapIn and $cowRef';$swapIn['b'] = 'This forces $swapIn to split from its copy-on-write references';$ao['c'] = 'This no longer affects $swapIn, but still affects $cowRef';echo "\n--> swapIn:  ";var_dump($swapIn);echo "\n--> cowRef:  ";var_dump($cowRef);echo "\n--> ao:  ";var_dump($ao);//Actual output on PHP 5.3.0-dev (cli) (built: Jul 28 2008 00:21:59) :////--> swapIn:  array(2) {//  ["a"]=>//  string(32) "This affects $swapIn and $cowRef"//  ["b"]=>//  string(62) "This forces $swapIn to split from its copy-on-write references"//}////--> cowRef:  array(2) {//  ["a"]=>//  string(32) "This affects $swapIn and $cowRef"//  ["c"]=>//  string(57) "This no longer affects $swapIn, but still affects $cowRef"//}////--> ao:  object(ArrayObject)#1 (1) {//  ["storage":"ArrayObject":private]=>//  array(2) {//    ["a"]=>//    string(32) "This affects $swapIn and $cowRef"//    ["c"]=>//    string(57) "This no longer affects $swapIn, but still affects $cowRef"//  }//}?>