NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
step thru a small block of code w/o going thru whole script?


Joined: 10 Jul 2012
Posts: 4
Reply with quote
Sorry -I am a newbie so be kind.

i am trying to step through a small block of code without going through the entire script from the beginning and all the calls to the DB and other include scripts?

is this possible? how? I can't seem to get "the set execution point" to work. It says that the code section is not in teh current context or
View user's profileFind all posts by jptrader1Send private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
You might need to show a code sample, but with Set execution point you can only set to a statement that is within the current function (context). You cannot set it directly back to a calling function because that would muck up the call stack, local variables, etc. However, you can for example set execution to the end of a function then step out. PHP is actualled fairly relaxed about context compared with many other languages.

First off, be aware that NuSphere Dbg is the only PHP debugger that I'm aware of that lets you set the execution point. Xdebug and Zend Debugger do not. This capability is in fact one of the major reasons that I use PhpED and it is incredibly useful.

Debugging is something that takes a bit of practice. You will work out techniques for testing your code, such as being able to set a couple of execution points to quickly get back to a caller, or step out to finish a function quickly. You can also setup special test calls to complex functions so you can repeatedly work them thoroughly maybe with different parameters.

Using breakpoints with Conditions can be a good way of getting to a point more quickly where you can check some code. Be careful when using your own debug PHP within your code, as there is always a risk of leaving that debug code in when you publish. However, DebugBreak() can be useful, so you could for example define a constant to enable your debug code.

Code:

define('DEBUG_MODE', true);
.
.
.
if (DEBUG_MODE && $customer->id == 22) {
    DebugBreak();
}


Many people use the PHPUnit Testing framework, which allows you to write various tests to check functionality. PHPUnit has various framework support to assist with testing. You might not want to use PHPUnit at the moment but it is worth remembering for the future.
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Unckeck "Break on start" in the debugger settings, set breakpoint on the line where you want debugger to stop, open file you want to execute, and click Run In Debugger (F9)

Regarding Set Execution Point -- it allows you to repeat just executed line by setting EP back to it to skip some lines by setting EP in forward direction -- but all lines should within the same block of code (method of function).

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
step thru a small block of code w/o going thru whole script?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic