【发布时间】:2014-10-06 10:01:25
【问题描述】:
我用 Magento 函数 setData 设置了一些值:
$this->getChild('childBlockName')->setData('search_field_value', $this->__('field value'));
在父 .phtml 文件中。
然后,在子 .phtml 文件中,我尝试获取值:
echo $this->search_field_value.'<br />';
$testvar = empty($this->search_field_value) ? 'empty value':'non empty value';
echo $testvar;
回声:
'field value'
'empty value'
和:
$testvar = $this->search_field_value;
$testvar2 = empty($testvar) ? 'empty value':'non empty value';
echo $testvar2;
回声:
'non empty value'
为什么对象的属性只有在分配给变量后才被识别为非空?
【问题讨论】:
标签: php magento object properties