Operators
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Please don't hijack other user's topics. I have split this into it's own as it is not related to the original topic in which it was posted.
= -> assignment operator:
sets the value of $i as 10.
== -> comparison operator:
tests whether $i has a value of 10
!= -> comparison operator:
tests whether $i is not equal to 10
For more information:
http://php.net/language.operators
Mac
= -> assignment operator:
Code: Select all
$i = 10;== -> comparison operator:
Code: Select all
if ($i == 10) {!= -> comparison operator:
Code: Select all
if ($i != 10) {For more information:
http://php.net/language.operators
Mac
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
= is assignment operator, i.e. after such code is executed:
variable $a will hold the value '3'
== is equality operator [bool]. It returns true if the both operands are equal and false otherwise.
!= is inequality operator [bool]. It returns false if the both operands are equal and true otherwise.
There are also exists === and !==
Code: Select all
$a=3;== is equality operator [bool]. It returns true if the both operands are equal and false otherwise.
!= is inequality operator [bool]. It returns false if the both operands are equal and true otherwise.
There are also exists === and !==
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
there are some other operators
=== checks whether values are equal or are the same type
!== means the values are not identical i.e. not the same value or data type
Mark
=== checks whether values are equal or are the same type
Code: Select all
$a = 2; //Integer
$b = "2"; //String
if($a === $b) {
//This would return false
}Mark