get_defined_vars is about to (citation):
return a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables
well, for my debugging task, I need only those user-defined. Is there php-built-in or supplement function?
EDIT: Ok I didn't made clear what exactly I was after, here is little example:
<?php
/*
this script is included, and I don't have info
about how many scripts are 'above' and 'bellow' this*/
//I'm at line 133
$user_defined_vars = get_user_defined_vars();
//$user_defined_vars should now be array of names of user-defined variables
//what is the definition of get_user_defined_vars()?
?>
Yes you can:
<?php
// Start
$a = count(get_defined_vars());
/* Your script goes here */
$b = 1;
// End
$c = get_defined_vars();
var_dump(array_slice($c, $a + 1));
Will return:
array(1) {
["b"]=>
int(1)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With