Although xdebug is available, log or var_dump is usually used for debugging.
I often want to know the current variable status when executing a certain point. I came back today and found the following information on the PHP Official Website: kailashbaduCodeWrite one.
The core is the get_defined_vars () function. In addition, the get_defined_constants () function is used to retrieve all constants.
/*** @ DESC show the variable that are to be excluded from the list. * $ varlist array * $ excludelist array */function logvars ($ varlist, $ excludelist = NULL) {if ($ excludelist = NULL) $ excludelist = array ('globals ', '_ FILES', '_ cookies',' _ Post', '_ get'); $ list = array (); foreach ($ varlist as $ key => $ value) {If (! In_array ($ key, $ excludelist) $ list [$ key] = $ value;} echo '<PRE>'; print_r ($ list ); echo '</PRE>';} // some dummy variables; add your own or include a file. $ firstname = 'kailash '; $ lastname = 'badu'; $ test = array ('pratistha', 'sanu', 'fuchhi'); logvars (get_defined_vars ()); // results/* array ([firstname] => Kailash [lastname] => Badu [test] => array ([0] => pratistha [1] => sanu [2] => fuchhi )) */
Reference: http://cn.php.net/manual/en/function.get-defined-vars.php