Breakpoints not working in Eclipse PHP with XDebug?
A strange error I encountered is that the debugger will not ever stop on breakpoints set on the first line of a multi-line array definition. For example:
$dood = array(
0 => 'hello',
1 => 'world'
);
Breakpoints on the first line aren't reached.
Written by Shanly Suepaul
Related protips
1 Response
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.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#