就像Zend Framework 1.x的问题一样,测试占位符值是否设置(或是否包含内容)的正确方法是什么?
我知道我可以做
$content = $this->placeholder('something')->getValue();
if (!empty($content)) {
echo $content;
}
但我宁愿直接查一下。类似的东西
if (.. test $this->placeholder('something') has content ..) {
echo $this->placeholder('something');
}
这三条线呢:
if (null != ($content = $this->placeholder('something')->getValue())) {
echo $content;
}
它并不完全等于空,但它正在接近。它将显示"0",而empty()不会显示。请参阅此代码板