search
Homephp教程php手册Xdebug文档(二)变量显示特性,xdebug文档

Xdebug文档(二)变量显示特性,xdebug文档

Xdebug能替代PHP的var_dump()函数来显示变量值。xdebug的版本包含对不同数据类型作数组元素/对象属性、最大深度和字符串长度以不同颜色标识。这里也有一些功能能很好地处理变量显示。

 

相关设置:

xdebug.cli_color

类型: integer, 默认值: 0, 始于 2.2版以上

设置为1时,xdebug会在CLI模式下且在tty终端输出时,会以有色显示var_dump跟踪输出的文字。window下, ANSICON工具需要安装。

设置为2时,则不管是否连接到tty终端或ANSICON是否被安装,xdebug会一直用颜色显示var_dump和调试跟踪信息。这种情形下,你可能在结束处看到转义码。

 

xdebug.overload_var_dump

类型: boolean, 默认值: 2(2.4版之前,该默认值为1), 始于 2.1版以上

xdebug默认情况下会过载var_dump()函数使用自己的改进版本来显示变量,如果html_errors在php.ini设置为1或2时。如果你真不要这样的设置,可以将此设置设为0,但你要确认它没智能地关闭了html_errors。

建议你使用2值。除了它能美观地格式化显示var_dump()输出,还会输出显示文件名和行号。另外xdebug.file_link_format也相应提供了(2.3版本新特性)。

 

xdebug.var_display_max_children

类型: integer, 默认值: 128

在使用 xdebug_var_dump(),xdebug.show_local_vars 或 追踪函数时,该设置控制数组元素和对象属性的数量显示。

若不受限制,可以设为-1值。

该设置不受Remot_Debuggin远程调试的任何影响。

 

xdebug.var_display_max_data

类型: integer, 默认值: 512

在使用 xdebug_var_dump(),xdebug.show_local_vars 或 追踪函数时,该设置控制字符串长度显示最大值。

若不受限制,可以设为-1值。

该设置不受Remot_Debugging远程调试的任何影响。

 

xdebug.var_display_max_depth

类型: integer, 默认值: 3

在使用 xdebug_var_dump(),xdebug.show_local_vars 或 追踪函数时,该设置控制数组元素和对象属性的显示层级。

最大值为1023,你可以设为-1表示其最大值。

该设置不受Remot_Debugging远程调试的任何影响。

 

相关函数:

void var_dump( [mixed var [, ...]] )

显示变量的详细信息。

该函数已被xdebug覆盖,详见xdebug_var_dump()。

 

void xdebug_debug_zval( [string varname [, ...]] )

该函数用于显示一或多个变量的结构化信息,包含其类型、值和被引用信息。数组则循环递归探索元素值。该函数与PHP的debug_zval_dump()函数上实现不一样,它能解决变量本身需要传递给该函数的问题。Xdebug版本的函数更好地利用了变量名称在内部符号表中查找该变量而直接访问所有属性而无需处理变量传递给函数的问题。该函数返回的信息能更精确地表达zval信息。

Example:

<?<span>php
    </span><span>$a</span> = <span>array</span>(1, 2, 3<span>);
    </span><span>$b</span> =& <span>$a</span><span>;
    </span><span>$c</span> =& <span>$a</span>[2<span>];

    xdebug_debug_zval(</span>'a'<span>);
    xdebug_debug_zval(</span>"a[2]"<span>);
</span>?>

<span>/*</span><span>*
Returns:

a: (refcount=2, is_ref=1)=array (

    0 => (refcount=1, is_ref=0)=1,

    1 => (refcount=1, is_ref=0)=2,

    2 => (refcount=2, is_ref=1)=3)

a[2]: (refcount=2, is_ref=1)=3
</span><span>*/</span>

 

void xdebug_debug_zval_stdout( [string varname [, ...]] )

与xdebug_debug_zval()相同,但该函数不通过web API界面显示该信息,但会直接显示在stdout设备(例如可以运行在apache的单进程模式下并显示在终端)。

 

void xdebug_dump_superglobals()

该函数显示出超全局变量的元素值,要显示的值在php.ini的xdebug.dump.*中设置。例如php.ini中设置如下:

Example:

xdebug.dump.GET=*<span>
xdebug</span>.dump.SERVER=<span>REMOTE_ADDR

Query </span><span>string</span>:
?<span>var</span>=fourty%20two&<span>array</span>[a]=a&<span>array</span>[9]=<span>b

Returns</span>:<span>

Dump </span><span>$_SERVER</span>

<span>$_SERVER</span>['REMOTE_ADDR'] =

<span>string</span> '127.0.0.1' (length=9<span>)

Dump </span><span>$_GET</span>

<span>$_GET</span>['var'] =

<span>string</span> 'fourty two' (length=10<span>)

</span><span>$_GET</span>['array'] =

<span>array</span>

  'a' => <span>string</span> 'a' (length=1<span>)

  </span>9 => <span>string</span> 'b' (length=1<span>)

 </span>

 

void xdebug_var_dump( [mixed var [, ...]] )

该函数显示一或多个表达式的结构化详细信息,里面包含类型和值。数组则递归探索其元素值。

Example:

<?<span>php
</span><span>ini_set</span>('xdebug.var_display_max_children', 3<span> );
</span><span>$c</span> = <span>new</span><span> stdClass;
</span><span>$c</span>->foo = 'bar'<span>;
</span><span>$c</span>-><span>file</span> = <span>fopen</span>( '/etc/passwd', 'r'<span> );
</span><span>var_dump</span><span>(
    </span><span>array</span><span>(
        </span><span>array</span>(<span>TRUE</span>, 2, 3.14, 'foo'),
        'object' => <span>$c</span><span>
    )
);
</span>?>  

<span>/*</span><span>*
Returns:

array

  0 =>

    array

      0 => boolean true

      1 => int 2

      2 => float 3.14

      more elements...

  'object' =>

    object(stdClass)[1]

      public 'foo' => string 'bar' (length=3)

      public 'file' => resource(3, stream)
</span><span>*/</span>

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),