当我尝试从PHP对象检索值时,它返回null
假设对象是$Item。当我使用var_dump($Item)转储它时,会给出:当我尝试从PHP对象检索值时,它返回null,php,oop,null,Php,Oop,Null,假设对象是$Item。当我使用var_dump($Item)转储它时,会给出: 当我使用use var_dump($Item->productVariationID)时,它返回6114。。但是当我使用var_dump($Item->custom_text)时,它返回null。。我不明白这里有什么问题。请有人给我解释一下。你的对象中没有$Item->custom\u text也没有$Item->productVariationID你在课堂上有神奇的方法吗?没有。。我没有任何神奇的方法保护'\u p
当我使用use var_dump($Item->productVariationID)时,它返回6114。。但是当我使用var_dump($Item->custom_text)时,它返回null。。我不明白这里有什么问题。请有人给我解释一下。你的对象中没有
$Item->custom\u text
也没有$Item->productVariationID你在课堂上有神奇的方法吗?没有。。我没有任何神奇的方法保护'\u productVariationID'=>string'6114'(长度=4)。。这个怎么样??它给出了正确的值???@ijasnijas:它是$Item->\u productVariationID而不是$Item->\u productVariationID-这是最大的区别!最大的区别是什么??都是一样的对吧??你是说你跳过了下划线???@ijasnijas:是的,这就是区别
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