views:

109

answers:

1

how can i check if a Zend View Placeholder isset before echo-ing it out? as i am wanting to prepend " - " to it before outputting it.

i tried

echo isset($this->placeholder("title")) ? " - " . $this->placeholder("title") : "";

but i got

Fatal error: Can't use method return value in write context in D:\Projects\Websites\php\ZendFramework\LearningZF\application\layouts\scripts\layout.phtml on line 5

on a side note, how come when i got this error, why isnt it shown in the Error View Script? the error was shown in a blank page without layout.

A: 

For the cause of the fatal error see the Question PHP : can’t use method return value in write context.

So you could either use a temporary variable or $this->placeholder()->getRegistry()->containerExists("key") which returns a boolean.

echo ($this->placeholder()->getRegistry()->containerExists("title")) ? " - " . $this->placeholder("title") : "";
Benjamin Cremer