嘿如何從整個對象中獲取任何特定的屬性。 我有這個疑問如何獲取Symfony中Object的屬性
$portfolios = $this->getDoctrine()
->getRepository('MunichInnovationGroupBundle:PmPortfolios')
->findBy(array('user' => '1'));
foreach ($portfolios as $portfolio){
if($portfolio.isDefault == true){
$default_portfolio = $portfolio;
}
echo $portfolio.name;
}
完整的物體看起來像這樣
MunichInnovationGroup\Bundle\Entity\PmPortfolios Object
(
[id:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => 991654b4-aa73-11e1-bdce-4a7b883b8e17
[portfolioName:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => Umair Portfolio 1
[description:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => Thsi is the description for Umairs portfolio 1
[permalink:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => premalink
[sharingCode:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => asdbnvg123dg
[shared:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] =>
[sharedPortfolioCalls:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] =>
[isDefault:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => 1
[user:MunichInnovationGroup\Bundle\Entity\PmPortfolios:private] => Proxies\MunichInnovationGroupBundleEntityUmUsersProxy Object
我怎樣才能獲得ISDEFAULT價值?
在此先感謝
'$ obj-> property'但是如果它是私人的,您將無法訪問它,直到您使用['__get()'](http://www.php.net/manual/en/language。 oop5.overloading.php#object.get)。哦,我沒有讀過「交響樂」。我希望這可能會有所幫助。 – Leri