
內容簡介
這款 WordPress 外掛是 Kint PHP Debugger 的封裝,版本為 1.x。現在,您可以直接使用 d(),而無需使用 var_dump() 或 print_r(),也不需要任何格式化。
在調試網站時,您可以使用此工具,代替 var_dump()、print_r() 和 debug_backtrace()。
方便的工具
一些適用於 PHP 開發人員的方便工具:
d($var);:顯示可折疊式 UI 容器,以 “最豐富的方式” 顯示您的變數資料
ddd($var);:與 d() 相同,但它也執行 die() 以停止執行。
以下是 d() 的一些變化,可顯示您想要的顯示:
~d($var);:以純文本格式輸出。
+d($var);:忽略深度限制,輸出所有內容
!d($var);:顯示展開的豐富輸出
-d($var);:嘗試 ob_clean() 先前的輸出(在 HTML 中傾倒某些東西)
分析器
Kint 甚至包括一個簡單的分析器,可幫助您分析哪些程式碼塊比其他程式碼塊花費更多時間:
Kint::dump(microtime()); // 傳遞 microtime()
sleep(1);
Kint::dump(microtime(), 'sleep(1) 後');
sleep(2);
ddd(microtime(), '最終呼叫,在 sleep(2) 之後');
請參閱截圖 2,以查看在瀏覽器中輸出的內容。
管理列
當啟用此外掛時,“KINT ACTIVE” 指示器會顯示在 WordPress 管理列中,以便提醒您。
外掛標籤
開發者團隊
原文外掛簡介
This WordPress plugin is a wrapper for the Kint PHP Debugger utility version 1.x. Now instead of using var_dump() or print_r(), you simply use d() with zero, nadda, no formatting required.
Use this tool when you are debugging your website, in place of var_dump(), print_r() and debug_backtrace().
Handy Tools
Some handy tools just for the PHP Developer:
d( $var ); to render a collapsible UI container which displays your variable data in “the most informative way”
ddd( $var ); same as d() except that it also executes die() to halt execution.
Here are some variations of d() to give you the display you want:
~d( $var ); outputs in plain text format.
+d( $var ); disregards depth level limits and outputs everything
!d( $var ); shows expanded rich output
-d( $var ); attempts to ob_clean() the previous output (dump something inside of HTML)
Profiler
Kint even includes a naïve profiler, which can help you analyze which blocks of code take longer than others:
Kint::dump( microtime() ); // just pass microtime()
sleep( 1 );
Kint::dump( microtime(), 'after sleep(1)' );
sleep( 2 );
ddd( microtime(), 'final call, after sleep(2)' );
See screenshot 2 for what is rendered out in your browser.
Admin Bar
“KINT ACTIVE” indicator displays in the WordPress admin bar to alert you when the plugin is active.
