Jump to content

Recommended Posts

Hell again guys,

ok this is my conditional statementL

if($class !== 7) {
header("Location: ". $redirectSuccess);
exit;
}

basically i am saying if $class is not 7 follow that instruction but it cycles through the statement anyway, what i am testing it on the vlaue of class is DEFINITELY 7

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/5463-conditional-statement/
Share on other sites

[!--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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.