Jump to content

Conditional statement


holowugz

Recommended Posts

[!--quoteo(post=357156:date=Mar 22 2006, 12:47 AM:name=jeepin81)--][div class=\'quotetop\']QUOTE(jeepin81 @ Mar 22 2006, 12:47 AM) [snapback]357156[/snapback][/div][div class=\'quotemain\'][!--quotec--]
get rid of the second equals sign and you should be all set.
best-
j.
[/quote]

...? , i thought == is the comparison operator and = was the operator to set something to something:

i.e $var = 7 (Is set To)
if($var == 7) (if Var equals 7)

does it differ in an if statement then?
Link to comment
https://forums.phpfreaks.com/topic/5463-conditional-statement/#findComment-19526
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]...? , i thought == is the comparison operator and = was the operator to set something to something:

i.e $var = 7 (Is set To)
if($var == 7) (if Var equals 7)
[/quote]
Yes, that is true, but we're looking at conditional operators:
== equal values
!= not equal values
=== equal types
!== not equal types

The difference here is usefull when comparing a return of "false" to a return of 0
This code [code]<?php $x = 0;
if ($x == false) echo "true"; else echo "false" ?>[/code]
will print "true", while this code
[code]<?php
$x = 0;
if ($x === false)echo "true"; esle echo "false" ?>[/code]
will print "false".

The first is comparing the values " 0 == 0" (false has the value of 0)
The second is comparing types " integer != boolean "

Ken
Link to comment
https://forums.phpfreaks.com/topic/5463-conditional-statement/#findComment-19538
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.