Search code examples
phpechovar-dump

PHP output wrong way around


Hopefully a simple one to replicate (assuming it's not my setup...)

I have the following in a PHP script:

echo('$userID:&emsp;' . var_dump($userID) . '<br>');
echo('$hashValidate:&emsp;' . var_dump($hashValidate) . '<br>');

The output is showing as:

bool(false) $userID:
bool(false) $hashValidate: 


Shouldn't it be this way around though?

$userID: bool(false)
$hashValidate: bool(false)


Solution

  • No. var_dump() performs IMMEDIATE output, and has no return value. That means your code is running the same as if you had

    var_dump($var)
    echo('$userID:&emsp;<br>');
    

    You'd need this instead:

    echo '$userID:'
    var_dump(...);
    echo '<br>';