mrneilrobinson Posted July 29, 2009 Share Posted July 29, 2009 hi there i am using the code //greater than operator //returns true if left side is greater than the right //returns false here $result = ($mean > $medium); but how do i get it to display the result of true or false? sos regards neil Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/ Share on other sites More sharing options...
waynew Posted July 29, 2009 Share Posted July 29, 2009 Have you tried using IF statements? Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/#findComment-886212 Share on other sites More sharing options...
p2grace Posted July 29, 2009 Share Posted July 29, 2009 Example of using if statement: if($mean > $medium){ echo "mean is greater than medium"; }else{ echo "mean is not greater than medium"; } Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/#findComment-886229 Share on other sites More sharing options...
Mark Baker Posted July 29, 2009 Share Posted July 29, 2009 $result = ($mean > $medium); echo 'Result is '.(($result) ? 'true' : 'false').'<br />'; Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/#findComment-886287 Share on other sites More sharing options...
KevinM1 Posted July 29, 2009 Share Posted July 29, 2009 $result = ($mean > $medium); echo 'Result is '.(($result) ? 'true' : 'false').'<br />'; The ternary operator may not be the best thing to show a beginner who doesn't know about conditional statements.... Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/#findComment-886296 Share on other sites More sharing options...
Mark Baker Posted July 29, 2009 Share Posted July 29, 2009 $result = ($mean > $medium); echo 'Result is '.(($result) ? 'true' : 'false').'<br />'; The ternary operator may not be the best thing to show a beginner who doesn't know about conditional statements.... Perhaps but he understands enough to know that $result = ($mean > $medium); will give him a boolean value in $result.... a lot of beginners wouldn't appreciate that. Link to comment https://forums.phpfreaks.com/topic/168024-comparison-operators/#findComment-886302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.