php - ArrayObject::getIterator error -
this how trying apartments name database, getting er error. how trying apartments names
$userapt = $user->getapartments()->getiterator(); while ($userapt->valid()) { echo ($userapt->key() . ' => ' . $userapt->current()) . "\n"; $userapt->next(); } $useraptname = $user->getapartment()->getiterator(); while ($useraptname->valid()) { ($useraptname->key() . ' => ' . var_dump($useraptname->current()) . "\n"); $useraptname->next(); }
running this, following error:
catchable fatal error: object of class mybundle\entity\userapartment not converted string 500 internal server error - contexterrorexception
how can error fixed?
in advance!
you trying echo
object
echo ($userapt->key() . ' => ' . $userapt->current()) . "\n";
you can solve implementing public function __tostring() {}
method in userapartament
class. in way when try echo $user->current()
use __tostring()
method show string value of object.
Comments
Post a Comment