Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to determine whether a variable is empty in PHP

3 Answers

0 votes
$var = 0;

if (empty($var)) 
    echo '$var is 0, empty, or not set';


/*
run: 

$var is 0, empty, or not set 

*/

 



answered Jun 15, 2016 by avibootz
0 votes
$var = 99;

if (empty($var)) 
    echo '$var is 0, empty, or not set';
else
    echo '$var is not empty';


/*
run: 

$var is not empty 

*/

 



answered Jun 15, 2016 by avibootz
0 votes
$var = 0;

if (isset($var)) 
    echo '$var is set but it is empty';


/*
run: 

$var is set but it is empty 

*/

 



answered Jun 15, 2016 by avibootz

Related questions

8 answers 385 views
2 answers 114 views
8 answers 548 views
1 answer 102 views
1 answer 134 views
1 answer 122 views
3 answers 218 views
...