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 7000693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:42:17+00:00 2026-05-27T20:42:17+00:00

I have encounteed an issue with php treating 0 differently. I run following script

  • 0

I have encounteed an issue with php treating “0” differently.

I run following script on 2 different machines:

$a = "0";
if ($a) {
    echo("helo");
}

1) Local Machine -> PHP 5.2.17
-> it treated “0” as valid and print the ‘helo’

2) Server -> PHP 5.3.6
-> it treated “0” as empty/false and won’t print the ‘helo’

Is this due to the php configuration (if yes, what configuration) or php version?

  • 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-27T20:42:18+00:00Added an answer on May 27, 2026 at 8:42 pm

    That’s how it is supposed to. PHP interprets strings in boolean context. The "0" there is equivalent to an actual 0. (See also http://www.php.net/manual/en/types.comparisons.php)

    What you meant to test for is probably:

    if (strlen($a)) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a PHP script that uses $_REQUEST[] superglobal. A typical client request
I have the following issue. I have a google map (using YM4r + Geokit)
We are facing a weird issue. We have NFS set up with 2 machines
I have got the following issue, my function appends code to a string $string
I am implementing instrumentation within an application and have encountered an issue where the
Recently I have encountered an issue with Scribd where searching via Scribd API (docs.search)
I am working with multiple databases in a PHP/MySQL application. I have development, testing,
have anyone encountered the issue wherein using a dynamic textfield without embedding fonts causing
I have encountered strange issue with lists in F#. I am using XamlXmlReader to
I have encountered a Hibernate issue I just can't find my way around. We're

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.