How can I capture the result of var_dump to a string?

后端 未结 13 1451
挽巷
挽巷 2020-11-27 08:39

I\'d like to capture the output of var_dump to a string.

The PHP documentation says;

As with anything that outputs its result directly to the

相关标签:
13条回答
  • 2020-11-27 09:39
    function return_var_dump(){
        // It works like var_dump, but it returns a string instead of printing it.
        $args = func_get_args(); // For <5.3.0 support ...
        ob_start();
        call_user_func_array('var_dump', $args);
        return ob_get_clean();
    }
    
    0 讨论(0)
提交回复
热议问题