Sample Code for debugging the debug_backtrace function in PHP,
Preface
If we want to know who called a method? Debug_backtrace can solve this problem. Debug_backtrace () can print out the call process of a page, from where to see clearly.
Sometimes we want to know the call stack of this function or method, that is, how it is called at the first level. We can print it using the debug_backtrace function of PHP, just like this:
Sample Code
Public function update (Request $ request, $ id) {dd (debug_backtrace (); $ getGameID = function ($ request) {if (! $ Request-> game_id) {return 1000 + intval ($ request-> id);} return $ request-> game_id ;}; $ previews = $ this-> getGamePreviews ($ request-> game_preview); $ request-> merge (['game _ preview' => json_encode ($ previews ), 'game _ id' => $ getGameID ($ request)]); EgretGame: where ('id', $ id) -> update ($ request-> token T (['_ token',' _ method']); return redirect ()-> route ('egretgame. index')-> with ('success', 'edited! ');}
You can control the number of stack levels to be traced back. The first parameter of debug_backtrace is a constant by default.DEBUG_BACKTRACE_PROVIDE_OBJECTThe information of this object is displayed. The second parameter is used to control the number of backtracing stacks. The default value is all.
Results:
PHP official documentation: http://php.net/manual/zh/function.debug-backtrace.php
Summary
The above is all the content of this article. I hope the content of this article has some reference and learning value for everyone's learning or work. If you have any questions, please leave a message to us, thank you for your support.