Meg_Griffin Posted October 16, 2012 Share Posted October 16, 2012 Hi guys,please help me with my code. Everything is fine,except for this line: elseif (3.2<$media<7) echo "Em recuperação"; It generates a syntax error: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\questao_01.php on line 49 So,the question is: if the specified condition in my exercise is 3.2<media<7 why is this wrong? . Link to comment Share on other sites More sharing options...
niche Posted October 16, 2012 Share Posted October 16, 2012 (edited) } elseif (3.2<$media<7) {echo "Em recuperação";} Based on your question as written. Edited October 16, 2012 by niche Link to comment Share on other sites More sharing options...
Ingolme Posted October 17, 2012 Share Posted October 17, 2012 The problem is that you're trying to make two comparisons in one statement. You need to separate them: elseif (3.2 < $media && $media < 7) Curly braces are not a requirement and it is syntactically correct to omit them. The only problem being that only the next line of code will be considered part of the block. 1 Link to comment Share on other sites More sharing options...
niche Posted October 17, 2012 Share Posted October 17, 2012 (edited) not considered part of the block. As in not part of the if-elseif structure? Edited October 17, 2012 by niche Link to comment Share on other sites More sharing options...
Ingolme Posted October 17, 2012 Share Posted October 17, 2012 You misquoted my post. When curly braces are omitted only one line of code is considered the part of the block of code that is associated with the keyword. The keyword can be if, else, elseif, else if, for, while, foreach. Link to comment Share on other sites More sharing options...
niche Posted October 17, 2012 Share Posted October 17, 2012 Thanks for the clarification fox. Link to comment Share on other sites More sharing options...
Meg_Griffin Posted October 17, 2012 Author Share Posted October 17, 2012 Ingolme,thank you.But there's one more doubt...why does this code show me a different output? It outputs "reprovado" instead of "sem notas cadastradas". elseif ($media=="indefinido") echo "Sem notas cadastradas"; Link to comment Share on other sites More sharing options...
birbal Posted October 17, 2012 Share Posted October 17, 2012 please post your relevant code Link to comment Share on other sites More sharing options...
Ingolme Posted October 17, 2012 Share Posted October 17, 2012 You'll need to post the whole if() structure and make sure that the values you are giving are what you expected them to do. Link to comment Share on other sites More sharing options...
Meg_Griffin Posted October 18, 2012 Author Share Posted October 18, 2012 Thanks for your attention,guys. I've solved my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now