如果没有't存在url,显示404错误


Show 404 error if doesn't exist url

我有一个CodeIgniter 404错误的问题。我有in controller:

public function show($id = 0)
{
    $review = $this->site_reviews->get_review($id);

    if ($review)
    {
              .....
    }
    else
    {
        show_404();
    }

现在如果我添加到链接的末尾例如:/?Id =13865或/? Id =42788?一切顺利…如何显示404()..存在解决方案吗?

当您的id为codigniter格式时:

$ id = $ this -> ->段(3)/uri/url: www.example.com/13865

在这种情况下,当你使用核心php概念时,get:

$ id = $ _GET [' id ']//url: www.example.com ? id = 13865

public function show($id = 0)
{
    $review = $this->site_reviews->get_review($id);

    if ($review)
    {
              .....
    }
    else
    {
        show_404();
    }