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

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

The Archive Base Latest Questions

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

So my code in the past needed a variable to run through 2 functions

  • 0

So my code in the past needed a variable to run through 2 functions and then return the value as such.

 function 1($variable) {
    check($variable);
    return $variable // either a -1, -2 or true;
 }

 // pass the return to next function

function 2($variable) {
    check($variable);
    return $variable // either a -1, -2 or true;
}

On the next check it returns a message to the user as such:

  if($variable == -1) // display message
  if($variable == -2) // display message
  if($variable == true) // display message

Now, per requirement of work the variable must go through a 3rd function check still returning a -1, -2 or true and then go onto the final if statements for display.
Now this is where it gets odd. If I keep it at 2 functions the if statements work, however if I run it through the 3rd check function I need to format my if’s like this in order to correctly check the return:

if($variable === -1) // display message
if($variable === -2) // display message
if($variable === true) // display message

Notice I have to add the 3rd ‘=’ symbol. I just can’t figure out why this is happening. Is this normal by some PHP law I don’t know about or is this a bug?

  • 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-27T06:45:48+00:00Added an answer on May 27, 2026 at 6:45 am

    This is not odd behavior, it’s very natural for PHP.

    Following expression:

    if ($variable == true) {
    }
    

    means that PHP will cast left operand to less pretensive type(in this case BOOLEAN) and do comparison after this. Which obviously will result in TRUE if $variable value is not 0 or FALSE or NULL or ”

    In second case i.e. === there is strict check value and type of both operands are compared.

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

Sidebar

Related Questions

Hi can anyone past some code how to do a restful web service get
I have been looking over this code for the past hour, I cant see
I have used traditional version control systems to maintain source code repositories on past
In the past I used to configure .NET code groups with the Mscorcfg.msc utility.
In past, I am using Listview and using below code can show a particular
I have used the code supplied in the following CodeProject article in the past
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code I have: cell_val = CStr(Nz(fld.value, )) Dim iter As Long For iter =
From what I've seen in the past, StackOverflow seems to like programming challenges, such
I'm working through Josh Smith's code and article on CommandSink which is a solution

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.