serikd
(Serik Drozd)
1
Hi.
How can I say Yii2 brake the current view and return to layout?
I have a view which can’t have all data and I want to do something like this in native PHP
if (empty($var)) {
echo "Sorry that's all we have for you";
return;
}
echo 'Some big data';
Can I use return statment or maybe Yii2 have something like $this->enoughGoToNextView(); ?
Thanks
softark
(Softark)
2
This will work just as you expect, when it is written in your view script. Just try it.
serikd
(Serik Drozd)
3
I used this.
<?php if (empty($var)): ?>
Some content
<?php return; endif; ?>
Some big content
Works fine, but I don’t know if that normal practice with Yii2
softark
(Softark)
4
I think it’s a matter of taste, but I would write
<?php if (empty($var)): ?>
Some content
<?php else: ?>
Some big content
<?php endif; ?>