Page 1 of 1

Posted: Fri Feb 06, 2004 9:07 am
by malcolmboston
out of curiosity

whats hte difference between

=
==
and
!= (ive never heard of this one)

Posted: Fri Feb 06, 2004 9:15 am
by twigletmac
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:

Code: Select all

$i = 10;
sets the value of $i as 10.

== -> comparison operator:

Code: Select all

if ($i == 10) {
tests whether $i has a value of 10

!= -> comparison operator:

Code: Select all

if ($i != 10) {
tests whether $i is not equal to 10

For more information:
http://php.net/language.operators

Mac

Posted: Fri Feb 06, 2004 9:16 am
by malcolmboston
sorry twig

thank you very much for the information though :oops:

Posted: Fri Feb 06, 2004 9:17 am
by Weirdan
= is assignment operator, i.e. after such code is executed:

Code: Select all

$a=3;
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 !== ;)

Posted: Fri Feb 06, 2004 9:19 am
by malcolmboston
this might sound really idiotic but what the hell is bool, i keep on seeing it in the manual, but luckily the functions i use, i have pretty much mastered.

Posted: Fri Feb 06, 2004 9:21 am
by Weirdan
bool is stand for boolean. It's datatype for logical values (either true or false).

Posted: Fri Feb 06, 2004 9:23 am
by malcolmboston
ah, right, i understand now

but now another question

twiglet or no-one else has mentioned another type that i have just seen in a script on these forums
!==

is this the opposite of == (but then again, they are used in different situations) :?

Posted: Fri Feb 06, 2004 10:01 am
by JayBird
there are some other operators

=== 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
}
!== means the values are not identical i.e. not the same value or data type

Mark

Posted: Fri Feb 06, 2004 12:00 pm
by Weirdan
Bech100 wrote: === checks whether values are equal or are the same type
Actually, "whether values are equal and are the same type".