PHP中 VAR_DUMP()

VAR_DUMP($value)  输出 $value 的结构信息。不过有个小问题

 Manual 中的 tips: As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example).

大致意思是 会直接输出结果到浏览器  可以使用{输出控制函数}将其捕捉保存到字符串

函数如下:

 

 
  
funciton varDumpToString( $value )
{
ob_start ();
var_dump ( $str );
$result = ob_get_clean ();
return $result ;
}

为什么要这样 对比一下程序就可以明白

 
  
$value = " hello " ;

// 使用var_dump()
echo " Type of the value is: " . var_dump ( $value );
echo var_dump ( $value ) . " Type of the value is: "
// 两条命令都会输出 string(5)"hello"Type of the value is:

//怎么办 使用 varDumpToString($value);

echo " Type of the value is: " . varDumpToString( $value );
//见证 奇迹的时刻
//输出: Type of the value is:string(5)"hello"
 

转载于:https://www.cnblogs.com/vale/articles/2000184.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值