Home > php教程 > php手册 > php var_dump简单测试

php var_dump简单测试

WBOY
Release: 2016-06-13 09:55:02
Original
1082 people have browsed it

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


此函数显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开值,通过缩进显示其结构。

*/
function a_test($str)         //自定义函数
{
  echo "nhi: $str";         //输出参数
  var_dump(debug_backtrace());      //输出backtrace
}
a_test('friend');          //调用用户自定义函数

//再来看一个var_dump遍历对象实例吧

class foo {
private $a;
public $b = 1;
public $c='bKjia.c0m';
private $d;
static $e;
public function test() {
var_dump(get_object_vars($this));
}
}
$test = new foo;
var_dump(get_object_vars($test));
$test->test();

//注意:为了防止程序直接将结果输出到浏览器,可以使用输出控制函数来捕获此函数的输出,并把它们保存到一个例如 string 类型的变量中。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template