Var dump(): Difference between revisions

MorMythos (talk | contribs)
No edit summary
MorMythos (talk | contribs)
No edit summary
Line 20: Line 20:


===Example===
===Example===
"The form had been submitting for three days without saving anything. She finally dropped a
<code>$colors = ['red', 'green', 'blue'];</code><br>
<code>var_dump($user)</code> at the top of the handler and found it immediately: <code>NULL</code>.
<code>var_dump($colors);</code>
The object she had been passing around, calling methods on, treating as a fully formed thing,
 
had never been instantiated. It was nothing. It had always been nothing."
Outputs:
 
<pre>
array(3) {
  [0]=> string(3) "red"
  [1]=> string(5) "green"
  [2]=> string(4) "blue"
}
</pre>
 
Three items in the array. Each one identified by its position, its type, its length, and its value.
Nothing assumed. Nothing hidden.


===See also===
===See also===