I have a little problem with print_r function. Undoubtedly, I donβt understand something in his work ... Basically, I have an array of objects in this class:
public $fields = array();
Assigned as follows:
$oField = new Field(); $this->fields[$i] = $oField;
Now in the main class I am trying to get debugging information:
$this->debuginfo = print_r($this->fields, true);
When the value of $this->debuginfo it simply says "Array" - basically the array does not explode. If I do the usual print_r($this->fields); It gives the expected results.
This is my first time I try to use print_r to return results or display on the screen, so I'm sure I just missed something, but when reading the php documentation this is like how it will be implemented. What am I missing?
Thanks for any help!
Update: print_r($var, true) really returns the βexplodedβ variable properly, as I wrote it. Thanks to dev-null for their comment, which gave me some food for thought that led me to my problem.
source share