写时复制:
1 2
| $a = 'this is string'; $b = $a;
|
此时,$a和$b 在内存中指向同一地址, 当修改$a或者$b 的时候, 才会复制一份, 然后对复制的这份进行修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| 146 typedef struct _zend_refcounted_h { 147 uint32_t refcount;
149 union { 150 struct { 151 ZEND_ENDIAN_LOHI_3( 152 zend_uchar type, 153 zend_uchar flags,
155 uint16_t gc_info) 156 } v; 157 uint32_t type_info; 158 } u; 159 } zend_refcounted_h; 160 161 struct _zend_refcounted { 162 zend_refcounted_h gc; 163 }; 165 166 167 168 169 170 struct _zend_string { 171 zend_refcounted_h gc; 172 zend_ulong h; 173 size_t len; 174 char val[1]; 175 };
|