0
我涉及的Symfony2 2幾個對象與方法Symfony的2如何訪問對象(stdClass的)
\Doctrine\Common\Util\Debug::dump($article);
我有
array(1) { [0]=> object(stdClass)#267 (19) { ["__CLASS__"]=> string(30) "obbex\AdsBundle\Entity\AdsList" ["id"]=> int(33) ["username"]=> string(7) "aviator" ["email"]=> string(17) "[email protected]" ["telephone"]=> string(4) "5161"
["displayPhone"]=> string(3) "non" ["title"]=> string(14) "aviator jacket" ["description"]=> string(14) "aviator jacket" ["country"]=> string(6) "France"
["region"]=> string(13) "Ile de France" ["department"]=> string(5) "Paris" ["address"]=> string(15) "15, rue Dantzig" ["city"]=> string(5) "Paris" ["zipCode"]=>
string(5) "75015" ["statusPro"]=> string(3) "oui" ["creationtime"]=> string(8) "DateTime" ["updatetime"]=> string(8) "DateTime" ["publication"]=> bool(true) ["photos"]=> string(8) "Array(1)" } }
與
\Doctrine\Common\Util\Debug::dump($article[0]);
變量
我有訪問所述第一陣列時隙[0]
object(stdClass)#267 (19) { ["__CLASS__"]=> string(30) "obbex\AdsBundle\Entity\AdsList" ["id"]=> int(33) ["username"]=> string(7) "aviator" ["email"]=> string(17)
"[email protected]" ["telephone"]=> string(4) "5161" ["displayPhone"]=> string(3) "non" ["title"]=> string(14) "aviator jacket" ["description"]=> string(14) "aviator jacket" ["country"]=> string(6) "France" ["region"]=> string(13) "Ile de France"
["department"]=> string(5) "Paris" ["address"]=> string(15) "15, rue Dantzig" ["city"]=> string(5) "Paris" ["zipCode"]=> string(5) "75015" ["statusPro"]=> string(3) "oui" ["creationtime"]=> object(stdClass)#365 (3) { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2014-06-06T21:54:00+02:00" ["timezone"]=> string(12) "Europe/Paris" }
["updatetime"]=> object(stdClass)#366 (3) { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "-001-11-30T00:00:00+00:09" ["timezone"]=> string(12) "Europe/Paris" } ["publication"]=> bool(true) ["photos"]=> array(1) { [0]=> string(29) "obbex\AdsBundle\Entity\Photos" } }
如何訪問的第一個對象(stdClass的) 'obbex \ AdsBundle \實體\ AdsList' 我試過
\Doctrine\Common\Util\Debug::dump($article[0]->{'obbex\AdsBundle\Entity\AdsList'});
和
\Doctrine\Common\Util\Debug::dump($article[0]->'obbex\AdsBundle\Entity\AdsList');
沒有成功。