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

  • Home
  • SEARCH
  • 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 6212239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:28:47+00:00 2026-05-24T06:28:47+00:00

I am checking a variable using the following code to if(!empty($var) && $var ==

  • 0

I am checking a variable using the following code to

if(!empty($var) && $var == 1)
{
       // do some thing
}
elseif(!empty($var) && $var == 0)
{
       // do some thing
}

But the elseif is not working
If I removed the !empty then its working fine.
what is the problem on that

Can any one explain these and also differences between isset and !empty

  • 1 1 Answer
  • 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-05-24T06:28:49+00:00Added an answer on May 24, 2026 at 6:28 am

    Please peruse the documentation on what PHP considers to be empty.

    I’d rewrite your code as:

    if (isset($var)) {
        if ($var == 1) {
            ...
        } else if ($var == 0) {
            ...
        } else {
            // if you're that specific you should handle any other case as well
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After checking out code for the first time from a repository into Eclipse using
Okay, I am using the following code to navigate to a page in my
I've been using the is_nan() function (i.e. is-not-a-number) to check whether a variable taken
I am receiving the following graph response when checking users into Facebook using the
This should work, so I'm really perplexed about why it's not working. I'm checking
Consider the following code: string propertyName; var dateList = new List<DateTime>() { DateTime.Now };
This might not appear like a programming question, but inherently deals with code. I
I'm using Subversion to checkin a file on OSX. I have my EDITOR variable
How can I check if a variable has something in it? I tried checking
Checking to see if __name__ == '__main__' is a common idiom to run some

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.