Earlier I'm used CodeIgniter 3 and after now using CodeIgniter 4 .
this is my view
<title><?php echo $title; ?></title>
this is my controller
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
$data = [
'title' => 'My Real Title',
'heading' => 'My Real Heading',
];
return view('blog_view', $data);
return view('common/header')
// . view('home')
. view('flip-flop-slippers',$data)
. view('common/footer');
}
}
But after showing this error
Whoops! We seem to have hit a snag. Please try again later...
While loading the view, you closed the first view with a semicolon, then you returned the second view, can you try this way?
To which view you want to send the
$data
variable, please send it to that view. I sent it here for the example at first.
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
$data = [
'title' => 'My Real Title',
'heading' => 'My Real Heading',
];
return view('blog_view', $data)
. view('common/header')
. view('flip-flop-slippers')
. view('common/footer');
}
}
View 1
View 2
And result.