Wolfie Posted July 22, 2010 Share Posted July 22, 2010 theres issues with this, should be....if ( $community == 'Invision Power Board' ) { $you = "Cool"; } else { $you = "n00b"; } Either way works. Of course, it could also be if ( $you == $cool ) and refer to IPB. Link to comment Share on other sites More sharing options...
Jaggi Posted July 22, 2010 Share Posted July 22, 2010 Either way works. Of course, it could also be if ( $you == $cool ) and refer to IPB. of course in an ideal world it'd be: if ( $community = 'Invision Power Board' ) { $you = "Cool"; } else { $you = "n00b"; } Link to comment Share on other sites More sharing options...
DawPi Posted July 22, 2010 Share Posted July 22, 2010 of course in an ideal world it'd be: if ( $community = 'Invision Power Board' ) { $you = "Cool"; } else { $you = "n00b"; } if ( $community = 'Invision Power Board' ) Very good coder. :lol: ;) Link to comment Share on other sites More sharing options...
Fishfish0001 Posted July 22, 2010 Share Posted July 22, 2010 if ( $community == 'Invision Power Board' ) *cough cough* Link to comment Share on other sites More sharing options...
Jaggi Posted July 23, 2010 Share Posted July 23, 2010 if ( $community = 'Invision Power Board' ) Very good coder. :lol: ;) if ( $community == 'Invision Power Board' ) *cough cough* obviously i'm faced with newbs here (yea i said it :P). Idea was to say that everyones community always is ipb, hence "in an ideal world" :P. Link to comment Share on other sites More sharing options...
Fishfish0001 Posted July 24, 2010 Share Posted July 24, 2010 But the syntax... Link to comment Share on other sites More sharing options...
Wolfie Posted July 24, 2010 Share Posted July 24, 2010 But the syntax... [img] [/img] What about it? It looks fine to me as far as PHP syntax is concerned. Link to comment Share on other sites More sharing options...
Collin1000 Posted July 24, 2010 Share Posted July 24, 2010 What about it? It looks fine to me as far as PHP syntax is concerned. if statements require a double equal. so if ($wolifie = "awesome") in incorrect. it should be if ($wolifie == "awesome") Link to comment Share on other sites More sharing options...
Wolfie Posted July 24, 2010 Share Posted July 24, 2010 if statements require a double equal. so if ($wolifie = "awesome") in incorrect. it should be if ($wolifie == "awesome") You can do a single = in there. It would only change how it works (ie wouldn't be comparing the value, but rather setting it and on success the condition would be true). So in a perfect world, $community would always be set to Invision Power Board, so you wouldn't need to compare it, only set it. Link to comment Share on other sites More sharing options...
Collin1000 Posted July 24, 2010 Share Posted July 24, 2010 http://www.w3schools.com/php/php_if_else.asp Link to comment Share on other sites More sharing options...
Lewis P Posted July 24, 2010 Share Posted July 24, 2010 Yeah, you still don't require a double == in there, a single = works fine. Try it some day.$var = 'hello; echo $var; // hello if( $var = 'goodbye' ) { echo $var; //goodbye } Link to comment Share on other sites More sharing options...
Collin1000 Posted July 24, 2010 Share Posted July 24, 2010 Yeah, you still don't require a double == in there, a single = works fine. Try it some day.$var = 'hello; echo $var; // hello if( $var = 'goodbye' ) { echo $var; //goodbye } how come every manual everywhere uses two? Link to comment Share on other sites More sharing options...
Lewis P Posted July 24, 2010 Share Posted July 24, 2010 Honestly, I don't know. It's probably because the chance of you needing something to evaluate to TRUE is small, and that it's not really needed. Checked php.net though? Link to comment Share on other sites More sharing options...
Wolfie Posted July 24, 2010 Share Posted July 24, 2010 In most instances, you would be doing something likeif ( $imagesize = getimagesize( $filename ) ) { (code to parse) } So long as there's no error and $imagesize is filled with data, then the condition is true. Take a look at this code: http://php.net/manual/en/function.fopen.php if(($fh = fopen($rssFile,'w')) === FALSE){ die('Failed to open file for writing!'); } It's setting $fh to be the value of the file handler and if it fails (FALSE), then it executes. Link to comment Share on other sites More sharing options...
Enkidu Posted July 24, 2010 Share Posted July 24, 2010 Now I do agree that a single = is pragmatically correct but I fail to see the point of doing such a thing, because the else part of the if statement will never be executed unless there is a mysterious case where $community = 'Invision Power Board' would evaluate to false. <_< Link to comment Share on other sites More sharing options...
Wolfie Posted July 24, 2010 Share Posted July 24, 2010 Now I do agree that a single = is pragmatically correct but I fail to see the point of doing such a thing, because the else part of the if statement will never be executed unless there is a mysterious case where $community = 'Invision Power Board' would evaluate to false. <_< pssst, it's this thing called a joke... Link to comment Share on other sites More sharing options...
Enkidu Posted July 25, 2010 Share Posted July 25, 2010 pssst, it's this thing called a joke... which part? Link to comment Share on other sites More sharing options...
Wolfie Posted July 25, 2010 Share Posted July 25, 2010 which part? if ( $community = 'Invision Power Board' ) { $you = "Cool"; } else { $you = "n00b"; } Link to comment Share on other sites More sharing options...
Enkidu Posted July 25, 2010 Share Posted July 25, 2010 you call that a joke? <_< Link to comment Share on other sites More sharing options...
Wolfie Posted July 25, 2010 Share Posted July 25, 2010 As a matter of fact, Mister Data, it's something that requires a sense of humor to get. <_< Link to comment Share on other sites More sharing options...
Collin1000 Posted July 25, 2010 Share Posted July 25, 2010 And yet another topic is totally derailed. Link to comment Share on other sites More sharing options...
Guest Posted July 25, 2010 Share Posted July 25, 2010 And yet another topic is totally derailed. -1 for "My other account is Wolfie" Link to comment Share on other sites More sharing options...
Wolfie Posted July 25, 2010 Share Posted July 25, 2010 I found a good design... Link to comment Share on other sites More sharing options...
Lakai Posted July 25, 2010 Share Posted July 25, 2010 wow talk about going way off topic.. Link to comment Share on other sites More sharing options...
Mark Posted July 25, 2010 Share Posted July 25, 2010 I think Jaggi's joke went over a lot of heads :P how come every manual everywhere uses two? They're different things. A single = is of course an assignment operator, a double (or triple) = is a comparison operator. This is completely valid code: if ( $foo = bar() ) { // Is executed if bar() returns true. $foo is now true. } else { // Is executed if bar() returns false. $foo is now false. } On the other hand: if ( $foo == bar() ) { // Is executed if bar() returns the same value as whatever $foo is } else { // Is executed if bar() returns a different value as whatever $foo is } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.