利用php-console和Chrome开发者工具实现PHP应用的printf
首先安裝PHP-console這個Chrome擴展應用:
然后安裝服務器端的庫文件:https://github.com/barbushin/php-console
用PHP的composer安裝:
composer require php-console/php-console
如何在PHP代碼里使用這些庫文件:
首先用require引入__autoload.php:
獲得PhpConsole的handler句柄,調用start方法后即可使用:
$handler = PhpConsole\Handler::getInstance();
$handler->start();
一些常用的打印方式:
帶標簽打印效果:
$handler->debug(‘called from handler debug’, ‘some.three.tags’);
直接打印:
PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug(‘called from debug dispatcher without tag s’);
還有一種縮略形式:
PhpConsole\Helper::register(); // required to register PC class in global namespace, must be called only once - 注冊PC這個namespace
PC::debug(‘called from PC::debug()’, ‘db’);
PC::db(‘called from PC::__callStatic()’); // means “db” will be handled as debug tag
打印對象:
輸出:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的利用php-console和Chrome开发者工具实现PHP应用的printf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新空调第一次开多久时间(汉典新字的基本解
- 下一篇: apache2怎么知道从哪个默认文件夹下