bassplaya4string Posted October 26, 2006 Share Posted October 26, 2006 anybody see anything wrong with this code?[code]if ($score < 3){$image1 = "<img src = 'images/0-3.jpg'>";}else ($score => 4 && =< 7){$image2 = "<img src = 'images/4-7.jpg'>";}else ($score => 8 && =< 10){$image3 = "<img src = 'images/8-10.jpg'>";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25130-parse-error-unexpected-t_double_arrow/ Share on other sites More sharing options...
btherl Posted October 26, 2006 Share Posted October 26, 2006 PHP uses >= instead of =>, because => has another meaning.[code] if ($a >= 5) { $arr = array('fred' => 5); }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25130-parse-error-unexpected-t_double_arrow/#findComment-114587 Share on other sites More sharing options...
bassplaya4string Posted October 26, 2006 Author Share Posted October 26, 2006 I switched them but it came back with this error nowparse error, unexpected T_IS_SMALLER_OR_EQUAL[code]if ($score <= 3){$image1 = "<img src = 'images/0-3.jpg'>";}else if ($score >= 4 && <= 7){$image2 = "<img src = 'images/4-7.jpg'>";}else ($score >= 8 && <= 10){$image3 = "<img src = 'images/8-10.jpg'>";}}}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25130-parse-error-unexpected-t_double_arrow/#findComment-114590 Share on other sites More sharing options...
.josh Posted October 26, 2006 Share Posted October 26, 2006 [code]if ($score <= 3){$image1 = "<img src = 'images/0-3.jpg'>";}else if (($score >= 4) && ($score <= 7)){$image2 = "<img src = 'images/4-7.jpg'>";}else (($score >= 8) && ($score <= 10)){$image3 = "<img src = 'images/8-10.jpg'>";}[/code]or...[code]switch ($score) { case >= 8 : $image3 = "<img src = 'images/8-10.jpg'>"; break; case >= 4 : $image2 = "<img src = 'images/4-7.jpg'>"; break; case <= 3 : $image1 = "<img src = 'images/0-3.jpg'>"; break;}[/code]although i'm not sure i understand your logic here.. I mean, you have 3 different variables (image1,image2, image3) and depending on what score is, one of those 3 get changed. Are you going to later on check which one exists or something? I suppose that's all up to you on what you're doing. It just seemed odd to me.. Quote Link to comment https://forums.phpfreaks.com/topic/25130-parse-error-unexpected-t_double_arrow/#findComment-114614 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.