2011-11-06 90 views
0

假設對象是$ Item。當我放棄它使用的var_dump($項目)給出:當我嘗試從PHP對象中檢索值時,它返回null

object(ProductVariation_OrderItem)[29] 
    protected '_productVariationID' => string '6114' (length=4) 
    protected '_productVariationVersion' => string '4' (length=1) 
    protected '_productID' => string '4220' (length=4) 
    protected '_productVersion' => string '72' (length=2) 
    protected '_id' => null 
    protected '_quantity' => string '1' (length=1) 
    protected '_custom_text' => string 'erger ~~ gerger' (length=15) 
    protected '_custom_text_id' => string 'b266dfceb5db66c01f08d97c45ebccf1' (length=32) 
    public 'destroyed' => boolean false 
    protected 'record' => 
    array 
     'ID' => int 0 
     'ClassName' => string 'ProductVariation_OrderItem' (length=26) 
     'RecordClassName' => string 'ProductVariation_OrderItem' (length=26) 
    protected 'changed' => 
    array 
     empty 
    protected 'original' => 
    array 
     'ID' => int 0 
     'ClassName' => string 'ProductVariation_OrderItem' (length=26) 
     'RecordClassName' => string 'ProductVariation_OrderItem' (length=26) 
    protected 'components' => null 
    protected 'brokenOnWrite' => boolean false 
    protected 'brokenOnDelete' => boolean false 
    protected 'componentCache' => null 
    protected 'iteratorPos' => int 0 
    protected 'iteratorTotalItems' => int 1 
    protected 'failover' => null 
    protected '_object_cache' => 
    array 
     empty 
    protected '_xml_cache' => 
    array 
     empty 
    protected '_natural_cache' => 
    array 
     empty 
    protected 'customisedObj' => null 
    protected 'parent' => null 
    protected 'namedAs' => null 
    public 'class' => string 'ProductVariation_OrderItem' (length=26) 
    protected 'extension_instances' => 
    array 
     empty 

當我用用var_dump($用品 - > productVariationID)返回6114 ..但是當我用var_dump($用品 - > custom_text),它返回null ..我不明白這裏有什麼問題。請有人解釋我。

+0

你有你的一類魔術方法__get? – Vikk

+0

否..我沒有任何魔術方法 – IJas

回答

0

您的對象沒有$Item->custom_text也不$Item->productVariationID

+0

protected'_productVariationID'=>字符串'6114'(長度= 4)..這是怎麼回事?它給出了正確的價值? – IJas

+0

@ijasnijas:它是$ Item - > _ productVariationID不是$ Item - > _ productVariationID - 這是最大的區別! – genesis

+0

什麼是最大的區別?兩者都是一樣的嗎?你的意思是你跳過了下劃線? – IJas

相關問題