Welcome Guest, Not a member yet? Register   Sign In
Using view layouts echoes void return type.
#4

(This post was last modified: 07-12-2021, 07:32 AM by includebeer.)

This looks like an error in the user guide. You are right, extend() return void, there's nothing to echo.

PHP Code:
    /**
    * Specifies that the current view should extend an existing layout.
    * @param string $layout
    * @return void
    */
    public function extend(string $layout)
    {
        $this->layout $layout;
    


Source: https://github.com/codeigniter4/CodeIgni...w.php#L398

...and it's the same with section() and endSection().

This:
PHP Code:
<?= $this->extend('default'?>

<?= $this->section('content'?>
    <h1>Hello World!</h1>
<?= $this->endSection() ?>

...should be this:
PHP Code:
<?php $this->extend('default'?>

<?php $this->section('content'?>
    <h1>Hello World!</h1>
<?php $this->endSection() ?>
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply


Messages In This Thread
RE: Using view layouts echoes void return type. - by includebeer - 07-12-2021, 07:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB