Let's create a view for 404
errors that we can use around our application.
1. Start by creating a new view in our
views/error/
directory called404.php
.2. Let's add some very basic code to
404.php
that will inform the visitor that our application couldn't find the requested page.<div class="hero-unit"> <h1>Page Not Found</h1> </div>
3. In order for us to render this view, let's add another function called
error404
into ourlib/bones.php
file. This function will nicely display404
errors for us.public function error404() { $this->render('error/404'); exit; }
We created a simple view, called 404.php
, that we can show any time a 404
error occurs in our application. We then created a simple function called error404
in lib/bones.php
that renders error/404.php
and terminates the current script so no further actions occur.