Print PHP Call Stack

前端 未结 15 1639
清歌不尽
清歌不尽 2020-11-27 09:08

I\'m looking for a way to print the call stack in PHP.

Bonus points if the function flushes the IO buffer.

15条回答
  •  北海茫月
    2020-11-27 09:44

    phptrace is a great tool to print PHP stack anytime when you want without installing any extensions.

    There are two major function of phptrace: first, print call stack of PHP which need not install anything, second, trace php execution flows which needs to install the extension it supplies.

    as follows:

    $ ./phptrace -p 3130 -s             # phptrace -p  -s
    phptrace 0.2.0 release candidate, published by infra webcore team
    process id = 3130
    script_filename = /home/xxx/opt/nginx/webapp/block.php
    [0x7f27b9a99dc8]  sleep /home/xxx/opt/nginx/webapp/block.php:6
    [0x7f27b9a99d08]  say /home/xxx/opt/nginx/webapp/block.php:3
    [0x7f27b9a99c50]  run /home/xxx/opt/nginx/webapp/block.php:10 
    

提交回复
热议问题