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

[PHP's Variable handling function] var_export

不言
不言Original
2018-04-14 16:16:111288browse

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 ] )

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
*/?>

       

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!

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