1

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)

2

2 Answers 2

9

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>'; 
Sign up to request clarification or add additional context in comments.

1 Comment

I see, thanks for clarifying - and providing an alternative! I'll accept once the time limit has passed....
3

This code:

echo('$userID:&emsp;' . var_export($userID, true) . '<br>'); echo('$hashValidate:&emsp;' . var_export($hashValidate, true) . '<br>'); 

1 Comment

Lacks the information of MarcB's answer, but this method is arguably cleaner and at least matches more closely OP's expectations.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.