1 :<?php 2 :// Demo script for the BODY Debugger. 3 : 4 :include("debug.inc"); 5 : 6 :$me = debug_program("demo"); 7 : 8 :print("Initial Break Condition = ".$me->break_condition."<br>\n"); 9 : 10 :include("sub_func.inc"); 11 : 12 :function sub_func_local($x) 13 :{ 14 : $y = $x+3; 15 : return $y; 16 :} 17 : 18 :function test_func() 19 :{ 20 : global $me; 21 : 22 : for($i=0; $i<50; $i++) 23 : {
24 : $j=$j+$i;
25 : $k=$k+sub_func_local($j); 26 : sub_func(); 27 : print("Made it to line i=$i. Break Condition = ".$me->break_condition."<br>\n"); 28 : } 29 : 30 : return $k; 31 :} 32 : 33 :function test_slow() 34 :{ 35 :// To do something that is computationally intensive, turn off the debugger ... 36 :// Be warned, this stuffs up depth() evals & thus some step / step over functions. 37 : 38 : onstatement_deactivate(); 39 : 40 : for($i=0; $i<1000; $i++) 41 : $j=$j+$i; 42 : 43 : onstatement_activate(); 44 : return $j; 45 :} 46 : 47 :echo "\n========== Demo Program ===========<br>"; 48 :echo "\nEntering a function that itterates 50 times.<br>"; 49 :$result = test_func(); 50 :echo "\nMade it out of function test_func()!<br>"; 51 : 52 :echo "\nEntering a function that itterates 1000 times.<br>"; 53 :$result = test_slow(); 54 :echo "\nMade it out of function test_slow()!<br>"; 55 :echo "\n========== Test 6 ===========<br>"; 56 :echo "About to exit the script !!!<br>" ; 57 : 58 : 59 :?> 60 :