PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 28, 2022

[FIXED] How do I check if a $_GET parameter exists but has no value?

 October 28, 2022     get, is-empty, isset, php     No comments   

Issue

I want to check if the app parameter exists in the URL, but has no value.

Example:

my_url.php?app

I tried isset() and empty(), but don’t work. I’ve seen it done before and I forgot how.


Solution

Empty is correct. You want to use both is set and empty together

if(isset($_GET['app']) && !empty($_GET['app'])){
    echo "App = ".$_GET['app'];
} else {
    echo "App is empty";
}


Answered By - Jay Hewitt
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing