超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<unsetvar_export>
Last updated: Fri, 22 Jun 2007

var_dump

(PHP 3>= 3.0.5, PHP 4 , PHP 5)

var_dump -- 打印变量的相关信息

描述

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

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

提示: 为了防止程序直接将结果输出到浏览器,您可以使用输出控制函数(output-control functions)来捕获函数的输出,并把它们保存到一个 string 型的变量中。

可以比较一下 var_dump()print_r()

例子 1. var_dump() 示例

<pre>
<?php
$a
= array (1, 2, array ("a", "b", "c"));
var_dump ($a);

/* 输出:
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(3) {
   [0]=>
   string(1) "a"
   [1]=>
   string(1) "b"
   [2]=>
   string(1) "c"
  }
}

*/

$b = 3.1;
$c = TRUE;
var_dump($b,$c);

/* 输出:
float(3.1)
bool(true)

*/
?>
</pre>




add a note add a note User Contributed Notes
var_dump
jsheets at shadonet dot com
02-Jul-2004 07:31
I include a v_dump function in all my projects to make the <pre></pre> easier.

<?php
function v_dump($var, $exit = false)
{
   print '<pre>';
  var_dump($var);
   print '</pre>';

   if (true == $exit) {
       exit;
   }
}
?>

Then displaying variable is as easy as a simple function call, reducing three lines of code to one each time I want information about a variable.

Jason

<unsetvar_export>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22