1 (edited by CodeXP 2006-02-13 08:45)

Topic: Suggestion for change of the dump function

Didn't want to post this in the feature requests, as it's not really a feature as such. Still, I think it would be a good idea to change the dump() function a little. I use it quite extensively when modding, and the results may often include HTML code. This of course makes it a little hard to read, as the results ends up being parsed by the browser.

What I'm suggesting is a change from:

//
// Dump contents of variable(s)
//
function dump()
{
    echo '<pre>';

    $num_args = func_num_args();

    for ($i = 0; $i < $num_args; ++$i)
    {
        print_r(func_get_arg($i));
        echo "\n\n";
    }

    echo '</pre>';
    exit;
}

to something like this:

//
// Dump contents of a variable
//

function dump() {

    @ob_end_flush();

    echo '<pre>';

    ob_start();

    $num_args = func_num_args();

    for ($i = 0; $i < $num_args; ++$i)
    {
        print_r(func_get_arg($i));
        echo "\n\n";
    }

    $todump = ob_get_contents();
    ob_end_clean();

    echo pun_htmlspecialchars($todump).'</pre>';

    exit;
}