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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:49:03+00:00 2026-05-14T23:49:03+00:00

Whey does this evaluate to true? <?php $val2=0; //outputs that is an error123 if($val2==’error123′){

  • 0

Whey does this evaluate to true?

<?php


$val2=0;

//outputs that is an error123
if($val2=='error123'){
   echo 'that is an error123<br />';
}else{
   echo 'that is not an error123<br />';
}  
  • 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-14T23:49:03+00:00Added an answer on May 14, 2026 at 11:49 pm

    You’re comparing a string to an integer. To make the comparison the string is first converted to an integer. When 'error123' is converted to an integer it becomes 0.

    echo intval("error123");
    

    Result:

    0
    

    In the PHP manual there is an explanation for this behaviour.

    If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.

    There is a quick reference page PHP type comparison tables that shows you the result of various comparions. See the table “Loose comparisons with ==”. The interesting part with regard to this question is that 0 == "php" is shown as TRUE.

    There is also a page on type juggling. A user comment on that page gives nearly the exact same example as this.

    If you don’t want the type juggling use === instead of ==.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im a newbie in PHP (also JSON for that matter) but I am not
Not sure who is responsible for this error: Exception in thread main java.lang.OutOfMemoryError: PermGen
I have the following string.Format({0:MM/dd},item.ActDate) Not sure whey it still shows it in 01/09/2012.
i just cant do it, dont kno whey. How can I get the value
I'm trying to figure out how to get the clicked element whey using $(document).click()
I got this message when I tried to log off from a site: You
OK this is really bugging me now. Eventually I want to add some ifs
I have an ListActivity which use data from DB.. setListAdapter(new CursorAdapter(myCursor)); This view have
According to this : http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9f.html Quote: An untyped variable is not the same as
I have a strange question about Linq. I have this query: var results =

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.