Home > Backend Development > PHP Tutorial > [PHP's Variable handling function] var_export

[PHP's Variable handling function] var_export

不言
Release: 2023-03-23 21:00:01
Original
1310 people have browsed it

The content shared with you in this article is about [PHP's Variable handling function] var_export, which has certain reference value. Friends in need can refer to it

var_export

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

var_export — Export or return a string representation of a variable

Description:

mixed var_export ( mixed $expression [, bool $return ] )
Copy after login

Returns structural information about the variables passed to this function, similar to var_dump(), except that the returned representation is legal PHP code.

Returns a representation of a variable by setting the second parameter of the function to TRUE.

<!-- 比较 var_export() 和 var_dump(). --><pre class="brush:php;toolbar:false"><?php$a = array (1, 2, array ("a", "b", "c"));
var_export ($a);// print_r ($a);// var_dump ($a);/* 输出:
array (
  0 => 1,
  1 => 2,
  2 => 
  array (
    0 => &#39;a&#39;,
    1 => &#39;b&#39;,
    2 => &#39;c&#39;,
  ),
)
*/$b = 3.1;$v = var_export($b, TRUE);echo $v;/* 输出:
3.1
*/?>
Copy after login

       

The above is the detailed content of [PHP's Variable handling function] var_export. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template