willdikuloz Posted June 8, 2006 Share Posted June 8, 2006 [code]if ( $type == link ) {echo '<tr><td width="50"><img src="' .$type. '.gif"></td><td width="340"><a href="' .$link. '" target="_blank" class="postlink">' .$title. '</a></td><td width="50"><font size="1" face="verdana" color="#A5A5A5"><i>' .$dat. '</i></font></td></tr>';} else {echo '<tr><td width="50"><img src="' .$type. '.gif"></td><td width="340"><a href="view.php?view=' .$post. '" class="postlink">' .$title. '</a></td><td width="50"><font size="1" face="verdana" color="#A5A5A5"><i>' .$dat. '</i></font></td></tr>';}[/code]is it possible to put two words for example [code]if ( $type == link OR image )[/code]obviously "OR" doesn't work but is there anyway for it to look for 2 variables at one time? Link to comment https://forums.phpfreaks.com/topic/11454-if-type/ Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 [code]if ($type == 'link' || $type == 'image')[/code]Also there are the [!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]boolean or[!--colorc--][/span][!--/colorc--] " || " and the [!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]logical or[!--colorc--][/span][!--/colorc--] " or "; there is a very small difference between them. [thanks thorpe] Link to comment https://forums.phpfreaks.com/topic/11454-if-type/#findComment-43028 Share on other sites More sharing options...
trq Posted June 8, 2006 Share Posted June 8, 2006 [i]or[/i] is fine though is further down in precedence and may work a little differently.[code]if ($type == 'link' or $type == 'image')[/code] Link to comment https://forums.phpfreaks.com/topic/11454-if-type/#findComment-43052 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 [a href=\"http://www.php.net/manual/en/language.operators.logical.php\" target=\"_blank\"]Logical Operators[/a][quote]The reason for the two different variations of "and" and "or" operators is that they operate at different precedences. (See Operator Precedence.) [/quote][a href=\"http://www.php.net/manual/en/language.operators.php#language.operators.precedence\" target=\"_blank\"]Operator Precedence[/a]The logical "or" is fine, but keep in mind that it's lower in precedence than the assignment operators. [quote]of course this should be clear, but i think it has to be mentioned espacially:AND is not the same like &&for example:<?php $a && $b || $c; ?>is not the same like<?php $a AND $b || $c; ?>the first thing is(a and b) or cthe seconda and (b or c)'cause || has got a higher priority than and, but less than &&of course, using always [ && and || ] or [ AND and OR ] would be okay, but than you should at least respect the following:<?php $a = $b && $c; ?><?php $a = $b AND $c; ?>the first code will set $a to the result of the comparison $b with $c, both have to be true, while the second code line will set $a like $b and THAN - after that - compare the success of this with the value of $cmaybe usefull for some tricky coding and helpfull to prevent bugs :Dgreetz, Warhog [/quote](From PHP user notes) Link to comment https://forums.phpfreaks.com/topic/11454-if-type/#findComment-43066 Share on other sites More sharing options...
willdikuloz Posted June 8, 2006 Author Share Posted June 8, 2006 thanks alot, btw Jin > every other character in Marvel v Capcom period. Link to comment https://forums.phpfreaks.com/topic/11454-if-type/#findComment-43226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.