How to check if $_GET is empty in PHP

3 Answers

0 votes
// assume 'id' is your variable
// example: https://www.seek4info.com/main.php?id=
   
if (isset($_GET['id']) && empty($_GET['id'])) {
    echo '$_GET is empty';
}
  
  
        
/*
run:
   
$_GET is empty
   
*/


answered Apr 13, 2015 by avibootz
edited May 17, 2024 by avibootz
0 votes
if (empty($_GET)) {
    echo '$_GET is empty';
} else {
    echo '$_GET is not empty';
}
 
 
 
 
/*
run:
 
$_GET is empty
 
*/

 



answered May 17, 2024 by avibootz
0 votes
if (count($_GET) === 0) {
    echo '$_GET is empty';
} else {
    echo '$_GET is not empty';
}
 
 
 
 
/*
run:
 
$_GET is empty
 
*/

 



answered May 17, 2024 by avibootz

Related questions

1 answer 149 views
1 answer 287 views
1 answer 209 views
1 answer 201 views
1 answer 165 views
165 views asked Jun 29, 2015 by avibootz
1 answer 167 views
...