Joined March 2012
·

Derick Rethans

London, England
·
·
·

If you pass this through VLD (a disassembler, see http://derickrethans.nl/projects.html#vld) then it becomes clear what PHP does:

1 <?php
2 $dood = array(
3     0 => 'hello',
4     1 => 'world'
5 );
6 ?>
derick@whisky:/tmp $ php -dvld.active=1 test.php 
Finding entry points
Branch analysis from position: 0
Return found
filename:       /tmp/test.php
function name:  (null)
number of ops:  6
compiled vars:  !0 = $dood
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   3     0  >   EXT_STMT                                                 
         1      INIT_ARRAY                                       ~0      'hello', 0
   5     2      ADD_ARRAY_ELEMENT                                ~0      'world', 1
         3      ASSIGN                                                   !0, ~0
   7     4      EXT_STMT                                                 
         5    > RETURN                                                   1

branch: #  0; line:     3-    7; sop:     0; eop:     5
path #1: 0, 

As you can see, nothing happens on line 2 - the array is only init-ted on line three where "'hello', 0" is added.

Achievements
132 Karma
0 Total ProTip Views