1.找到當前運行php版本的配置文件:php.ini,比如php5.6,我的目錄是
D:\phpStudy\PHPTutorial\php\php-5.6.27-nts
2.打開上面目錄中的php.ini文件,搜索 XDebug ,會找到以下代碼
[XDebug]
xdebug.profiler_output_dir="D:\phpStudy\PHPTutorial\tmp\xdebug"
xdebug.trace_output_dir="D:\phpStudy\PHPTutorial\tmp\xdebug"
;zend_extension="D:\phpStudy\PHPTutorial\php\php-5.6.27-nts\ext\php_xdebug.dll"
默認 zend_extension 是注釋的,去掉前面的注釋符號,然后重啟apache或者nginx.
3.測試成果,在測試文件里輸出下phpinfo,成功的話會看到以下界面:
4.簡單使用實例:
$name = "張三";
$name2 = $name;
xdebug_debug_zval('name');
輸出:
name:
(refcount=2, is_ref=0),string '張三' (length=6)
5.php內存回收機制講解: