faqts : Computers : Programming : Languages : PHP : kms : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 15 people (87%) answered Yes
Recently 7 of 9 people (78%) answered Yes

Entry

What is the difference between = and ==?

Jun 27th, 1999 17:41
Nathan Wallace, Colin Viebrock, Nathan Wallace


The assignment operator (=) is used to assign a value to a variable. 
For example:

    $a = 23;
    // $a now holds the number 23

The equality operator (==) is used to compare two values for equality. 
For example:

    if ($a == 23) {
        // $a is equal to 23
    }
    else {
        // $a is not equal to 23
    }