webCOMAND

controller::show_404()

Produce a 404 Not Found response and exit, which is useful when a controller cannot locate a requested resource.  This is a shortcut to the static method view::show_404().

This method will send the error response and terminate PHP execution, so it never returns.

Prototype

void show_404(string $message = '', string $filename = NULL)

Parameters

  • message - Optional message to display on 404 page.  Can contain HTML.
  • filename - Optional path to a cMVC view that will receive the message as $message.

Example

// the show controller method
public function web__show($oid=0) {
    $repo = $this->repo();
    $object = $repo->get_by_oid($oid);
    if(!$object){
        $repo = $this->show_404('Object Not Found');
    }
    echo('Found object: ' . $object->Summary());
}