0

Like the question for Zend Framework 1.x, what is the proper way to test if a placeholder value is set (or if it contains content)?

I know I could do

$content = $this->placeholder('something')->getValue();
if (!empty($content)) {
   echo $content;
}

but I'd rather check this directly. Something like

if (.. test $this->placeholder('something') has content ..) {
   echo $this->placeholder('something');
}
Community
  • 1
  • 1
Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214

1 Answers1

0

What about this three liner:

if (null != ($content = $this->placeholder('something')->getValue())) {
    echo $content;
}

It's not exactly equal to empty, but it's coming close. It'll display "0" where as empty() would not. See this codepad

netiul
  • 2,737
  • 2
  • 24
  • 29