当我使用var_dump变量调试php时,总是在开始时输出文件路径吗? [英] When I debug php with var_dump variable it always outputs file path at the beginning?
问题描述
我将Ubuntu 7与PHP 7配合使用.
I am using Ubuntu with PHP 7.
PHP 7.0.5-3+donate.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
当我使用var_dump
显示一些变量来调试PHP脚本时:
When I debug a PHP script by using var_dump
to show some variable:
<?php
var_dump('tmp string');
var_dump(true);
以下是其输出:
/var/www/example.com/test.php:3:string 'tmp string' (length=10)
/var/www/example.com/test.php:4:boolean true
为什么总是与以前的文件路径一起输出?
Why does it always output with the file path before?
我希望它输出如下:
string 'tmp string' (length=10)
boolean true
推荐答案
您看到的输出来自Xdebug扩展. (不带扩展名的var_dump
输出纯文本,未格式化的文本.)
The output you're seeing is from the Xdebug extension. (Without the extension, var_dump
outputs plain, unformatted text.)
从Xdebug 2.3开始,设置xdebug.overload_var_dump
具有新的默认值2
,该默认值会将文件名和行号添加到对var_dump
的任何调用的输出中.有关更多信息,请参见文档.我同意这没什么用,特别是对于简单的输出(例如短字符串/数字).
From Xdebug 2.3, the setting xdebug.overload_var_dump
has a new default value of 2
which adds the filename and line number to the output from any call to var_dump
. See the docs for more info. I agree it's not that useful, especially for simple output like short strings/numbers.
要删除文件名,您可以在php.ini文件中将选项设置为旧值1
:
To remove the filename you can set the option to the old value of 1
in your php.ini file:
[xdebug]
xdebug.overload_var_dump = 1
这篇关于当我使用var_dump变量调试php时,总是在开始时输出文件路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!