Tuesday, September 17, 2013

[PHP] Print strclass Object - convert strclass object to text

If want print the strclass object directly ,using these code:

<?php
foreach ($query->result() as $row){
echo $row;
}?>

 would cause PHP error:

A PHP Error was encounteredSeverity: 4096Message: Object of class stdClass could not be converted to string
So how to convert that to text ?
you can use print_r function:



<?php
foreach ($query->result() as $row){
echo print_r($row)."<br />";
                }?>
:
Result:


No comments :

Post a Comment