debug_zval_dump Dumps a string representation of an internal zval structure to output
发表日期:2021-07-01 08:57:20 | 来源: | | 浏览(617) 分类:变量处理 函数
debug_zval_dump
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
debug_zval_dump — Dumps a string representation of an internal zval structure to output
说明
$value
, mixed ...$values
): voidDumps a string representation of an internal zval (Zend value) structure to output. This is mostly useful for understanding or debugging implementation details of the Zend Engine or PHP extensions.
参数
-
value
-
The variable or value to dump.
-
values
-
Further variables or values to dump.
返回值
没有返回值。
范例
示例 #1 debug_zval_dump() example
<?php $var1 = 'Hello'; $var1 .= ' World'; $var2 = $var1; debug_zval_dump($var1); ?>
以上例程会输出:
string(11) "Hello World" refcount(3)
注意: Understanding the
refcount
The
refcount
value shown by this function may be surprising without a detailed understanding of the engine's implementation.The Zend Engine uses reference counting for two different purposes:
- Optimizing memory usage using a technique called "copy on write", where multiple variables holding the same value point to the same copy in memory. When any of the variables is modified, it is pointed to a new copy in memory, and the reference count on the original is decreased by 1.
- Tracking variables which have been assigned or passed by reference (see References Explained). This refcount is stored on a separate reference zval, pointing to the zval for the current value. This additional zval is not currently shown by debug_zval_dump().
Because debug_zval_dump() takes its input as normal parameters, passed by value, the copy on write technique will be used to pass them: rather than copying the data, the refcount will be increased by one for the lifetime of the function call. If the function modified the parameter after receiving it, then a copy would be made; since it does not, it will show a refcount one higher than in the calling scope.
The parameter passing also prevents debug_zval_dump() showing variables which have been assigned by reference. To illustrate, consider a slightly modified version of the above example:
<?php $var1 = 'Hello'; $var1 .= ' World'; // Point three variables as references to the same value$var2 =& $var1; $var3 =& $var1; debug_zval_dump($var1); ?>以上例程会输出:
string(11) "Hello World" refcount(2)Although $var1, $var2, and $var3 are linked as references, only the value is passed to debug_zval_dump(). That value is used once by the set of references, and once inside the debug_zval_dump(), so shows a refcount of 2.
Further complications arise because of optimisations made in the engine for different data types. Some types such as integers do not use "copy on write", so do not show a refcount at all. In other cases, the refcount shows extra copies used internally, such as when a literal string or array is stored as part of a code instruction.
参见
- var_dump() - 打印变量的相关信息
- debug_backtrace() - 产生一条回溯跟踪(backtrace)
- References Explained
- » References Explained (by Derick Rethans)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- boolval 获取变量的布尔值(0)
- debug_zval_dump Dumps a string representation of an internal zval structure to output(0)
- doubleval floatval() 的别名(0)
- empty 检查一个变量是否为空(0)
- floatval 获取变量的浮点值(0)
- get_debug_type Gets the type name of a variable in a way that is suitable for debugging(0)
- get_defined_vars 返回由所有已定义变量所组成的数组(0)
- get_resource_id Returns an integer identifier for the given resource(0)
- get_resource_type 返回资源(resource)类型(0)
- gettype 获取变量的类型(0)
- intval 获取变量的整数值(0)
- is_array 检测变量是否是数组(0)
- is_bool 检测变量是否是布尔值(0)
- is_callable 检测参数是否为合法的可调用结构(0)
- is_countable Verify that the contents of a variable is a countable value(0)
- is_double is_float() 的别名(0)
- is_float 检测变量是否是浮点型(0)
- is_int 检测变量是否是整数(0)
- is_integer is_int() 的别名(0)
- is_iterable Verify that the contents of a variable is an iterable value(0)
- is_long is_int() 的别名(0)
- is_null 检测变量是否为 null(0)
- is_numeric 检测变量是否为数字或数字字符串(0)
- is_object 检测变量是否是一个对象(0)
- is_real is_float() 的别名(0)
- is_resource 检测变量是否为资源类型(0)
- is_scalar 检测变量是否是一个标量(0)
- is_string 检测变量是否是字符串(0)
- isset 检测变量是否已设置并且非 null(0)
- print_r 以易于理解的格式打印变量。(0)
- serialize 产生一个可存储的值的表示(0)
- settype 设置变量的类型(0)
- strval 获取变量的字符串值(0)
- unserialize 从已存储的表示中创建 PHP 的值(0)
- unset 释放给定的变量(0)
- var_dump 打印变量的相关信息(0)
- var_export 输出或返回一个变量的字符串表示(0)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)