I was trying to add Element in cakephp template page.
Documentation about Element in cakephp 3.0 says echo must be used.
echo $this->element('helloworld');
I follow documentation, but my website returns this error.
Error: syntax error, unexpected 'echo' (T_ECHO)
When I don't use echo, it works fine. I tried directly:
$this->element('helloworld');
someone have any explanation about this error ? and where is my error ?
if you are doing this <?= $this->element('helloworld'); ?>
then you don't need echo
. However, if you are doing this <?php echo $this->element('helloworld');
, then you need echo
.
The difference is whether you are using php's echo short syntax. <?=
vs <?php echo
and it has nothing to do directly with CakePHP. It is just PHP... More info here: http://php.net/echo
in view of cakephp 3.0 elements will be directly included. no need to use neither echo nor cakephp echoing syntax