I am very interested in @Sebastián Grignoli 's answer to this question but, when I try to execute it, I get Fatal error: Class 'dInspect' not found
.
Can anyone tell me how to rectify this? Thanks.
I am very interested in @Sebastián Grignoli 's answer to this question but, when I try to execute it, I get Fatal error: Class 'dInspect' not found
.
Can anyone tell me how to rectify this? Thanks.
As far as I can tell, it's some class he made. I googled and the only thing that comes up for "php dInspect" is this question..I also looked for member functions called "dump" in php-included libraries and found nothing.
You might be able to modify his answer a bit to get what you want, it looks pretty complete. (I didn't test anything though)
Here's a simplified version of the solution. Maybe you could adapt it to your needs with less trouble:
function catch_param($label)
{
$bt = debug_backtrace();
$src = file($bt[0]["file"]);
$line = $src[ $bt[0]['line'] - 1 ];
// let's match the function call and the last closing bracket
preg_match( "#catch_param\((.+)\)#", $line, $match );
/* let's count brackets to see how many of them actually belongs
to the var name
Eg: die(catch_param($this->getUser()->hasCredential("delete")));
We want: $this->getUser()->hasCredential("delete")
*/
$max = strlen($match[1]);
$varname = "";
$c = 0;
for($i = 0; $i < $max; $i++){
if( $match[1]{$i} == "(" ) $c++;
elseif( $match[1]{$i} == ")" ) $c--;
if($c < 0) break;
$varname .= $match[1]{$i};
}
// $varname now holds the name of the passed variable ('$' included)
// Eg: catch_param($hello)
// => $varname = "$hello"
// or the whole expression evaluated
// Eg: catch_param($this->getUser()->hasCredential("delete"))
// => $varname = "$this->getUser()->hasCredential(\"delete\")"
echo("The passed expression is: ".$varname);
}
If what you want is the inspection class, this is the download link:
http://download.inspect.jaku.com.ar/
Here's an example of the inspector function (and my dInspect class) in action:
Texts are in spanish in that page, but code is concise and really easy to understand.
When I google it, the first hit is a reference to the NuSphere debugger nusphere.com/products/php_debugger.htm since I don't have that, it looks like I am SOL.