php文档中对缓冲区有这样的描述:
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
那我们是不是能利用这一点将var_dump的结果捕获且赋值给某变量呢?
测试代码:
<?php ob_start(); var_dump($someVar); $result = ob_get_clean(); ?>