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 8709319

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:20:20+00:00 2026-06-13T04:20:20+00:00

Possible Duplicate: How to check if $_GET is empty? I’m trying to check for

  • 0

Possible Duplicate:
How to check if $_GET is empty?

I’m trying to check for the condition that there is any $_GET data in my urls ?var=foo&biz=bang, and the if statement I’m currently using to do this is isset($_GET) //Do something, but it’s return truey even though there isn’t even any ? or & anywhere in my URL. I’m assuming that the $_GET variable is always set, so how do I check for this?

Duplicate of “How to check if $_GET is empty?”

  • 0 0 Answers
  • 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-06-13T04:20:21+00:00Added an answer on June 13, 2026 at 4:20 am

    Since $_GET is always set in php (when run in a webserver), what you really want to know is “is anything in there?”

    You want to use:

    if ($_GET) {
    }
    

    This works because $_GET is an array, and an empty array will be evaluated false, while a populated array is true.


    UPDATE

    I no longer use the above method, since it has really negative effects on testability and CLI-run commands (phpunit, artisan).

    I now always check isset() on the $_GET array. I also usually assign to an array inside the if – php evaluates these expressions to the value of the assigned variable.

    If your framework has a “safe array access” function, you should always use it. If you framework has a “safe GET function” that’s even better.
    If you aren’t using a framework, or your framework does not include these helper functions, you should write them for yourself.

    // example with "safe array access"
    if (isset($_GET) && $value = safe_array($_GET, 'key')) {
        // do something with $value
    }
    
    // example with "safe GET function"
    if ($value = safe_input_get('key')) {
        // do something with $value
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Check that an email address is valid on iOS What is the
Possible Duplicate: Check if a variable is empty Simple PHP question: I have this
Possible Duplicate: Java: how to check that a string is parsable to a double?
Possible Duplicate: Check whether a Directory Exists in PHP I am trying scandir() to
Possible Duplicate: Check if access table exists I'm new to vba macros. Any idea
Possible Duplicate: Hash tables in MATLAB General Question Is there any way to get
Possible Duplicate: Is there a (built-in) way in JavaScript to check if a string
Possible Duplicate: ie8 var w= window.open() - “Message: Invalid argument.” check this page out:
Possible Duplicate: Conditional Check in Where clause I have a few parameters that I
Possible Duplicate: Validating url with jQuery without the validate-plugin? is there any jquery method

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.