Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4062286
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:34:46+00:00 2026-05-20T15:34:46+00:00

Possible Duplicate: Reference – What does this symbol mean in PHP? I’m making a

  • 0

Possible Duplicate:
Reference – What does this symbol mean in PHP?

I’m making a web application that uses URL queries to access different parts of the application. I was looking for a solution to make an invalid query like index.php?page=dashboarrrd display an error 404 message instead of a PHP error.

After some searching, I found that I could use something like the following to do the job:

if(!@include($fileName)){
    @include("pageData/404.php");
}

And that makes sense, but I don’t know why that works. I mean, what the heck does the @ before the include mean? I totally understand include $filename; but I need an explanation for @include ($fileName)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:34:47+00:00Added an answer on May 20, 2026 at 3:34 pm

    the code you really need is

    $fileName = "pagedata/".basename($_GET['page']).".php";
    
    if(is_readable($fileName)) {
        include($fileName);
    } else {
        include("pagedata/404.php");
    }
    

    and @ has absolutely nothing to do here

    @ is one of biggest delusions coming from lack of experience.
    Ones who using it do expect only one kind of error, while in fact there can be many more. And to gag ALL possible messages to suppress only one of them is definitely like to throw out the child along with the bath.

    There is a fundamental problem that makes such misunderstanding so widespread:

    Most PHP users cannot distinguish three sides of error control:

    1. error handling
    2. error reporting
    3. user notification.

    Most of time in sake of [3] people mess with (1) and (2). While each of them require separate treatment:

    1. your program should raise no intentional errors. No error should be part of program logic. All errors that ever raised should be only unexpected ones.
      if you expect some error, you have to handle it. Not gag with @, but gracefully handle. is_readable() in my code exactly for that.
    2. error reporting is for the programmer and should be always at max. So, error logging should be enabled on a live site and a programmer have to check all errors occurred. And of course he would be interested in such errors, thus @ will do only harm here.
    3. User-level error messages should be different from system ones. Your 404.php is a good example of such user-friendly behavior. As for the system error messages, a user shouldn’t be able to see them at all. Just turn display_errors off and see – there is no use for the @ again!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.