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 142 views
1 answer 278 views
1 answer 203 views
1 answer 195 views
1 answer 157 views
157 views asked Jun 29, 2015 by avibootz
1 answer 158 views
...