PHP var_export() 函数
PHP 教程
· 2019-01-31 22:43:06
var_export() 函数用于输出或返回一个变量,以字符串形式表示。
var_export() 函数返回关于传递给该函数的变量的结构信息,它和 var_dump() 类似,不同的是其返回的是一个合法的 PHP 代码。
PHP 版本要求: PHP 4 >= 4.2.0, PHP 5, PHP 7
语法
mixed var_export ( mixed $expression [, bool $return ] )
参数说明:
- $expression: 你要输出的变量。
- $return: 可选,如果设置为 TRUE,该函数不会执行输出结果,而且将输出结果返回给一个变量。
返回值
$return
设置为 true 时才有返回值,返回变量的结构信息。
实例
实例
$a = array (1, 2, array ("a", "b", "c"));
var_export ($a);
输出结果为:
array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), )
可选参数 $return
设置为 true:
实例
$b = 3.1;
$v = var_export($b, TRUE);
echo $v;
输出结果为:
3.1
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
The Art of Computer Programming, Volumes 1-3 Boxed Set
Donald E. Knuth / Addison-Wesley Professional / 1998-10-15 / USD 199.99
This multivolume work is widely recognized as the definitive description of classical computer science. The first three volumes have for decades been an invaluable resource in programming theory and p......一起来看看 《The Art of Computer Programming, Volumes 1-3 Boxed Set》 这本书的介绍吧!