Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is the difference between == and === in php

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 158
    Comment on it

    When comparing values in PHP for equality we can use either the == operator or the === operator. The == operator just checks to see if the left and right both values are equal. But, the === operator actually checks to see if the left and right values are equal, and also checks to see if they are of the same variable type (like whether they are both booleans, ints, etc.).

    PHP

    //bad code:
    if ( strpos( $inputString, 'ABC' ) == false ) {
    
        // do something
    }
    
    //good code:
    if ( strpos( $inputString, 'ABC' ) === false ) {
    
        // do something
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: