Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when var_dump reports the wrong string length?

I'm trying to figure out why a variable isn't triggering a conditional that it should. var_dump reports something like this:

string(20) "0"

Why is it reporting a length of 20 when the length is clearly 1?

like image 680
vamin Avatar asked May 09 '10 17:05

vamin


People also ask

What is Var_dump () used for?

The function var_dump() displays structured information (type and value) about one or more expressions/variables. Arrays and objects are explored recursively with values indented to show structure. All public, private and protected properties of objects will be returned in the output.

What is the meaning of Var_dump in PHP?

PHP | var_dump() Function The var_dump() function is used to dump information about a variable. This function displays structured information such as type and value of the given variable. Arrays and objects are explored recursively with values indented to show structure.


1 Answers

It might be rendering html. i.e. var_dump('<p class="abc">0</p>') would output string(20) "0" to the naked eye

like image 132
Mike B Avatar answered Sep 20 '22 13:09

Mike B