-7

I'm a student studying Application development and we're currently in a deep dive for PHP. I've only used and learnt off the language this monday. We've already gotten exercises concerning Tables, Arrays, etc. But I've gotten stuck at IfElse statements of all places. Could someone please explain why I get an error?

Basically I want it to react to the value of 19. So when it's above it'll say that Dutch message, or when it's lower it'll state the other question, visa versa.

$temperatuur = 19

if ($temperatuur > 20) {
    echo "Vandaag is het lekker warm. Namelijk 23 graden";
} elseif ($temperatuur > 10) {
    echo "Het is weer om een dun jasje aan te trekken";
} else ($temperatuur < 10) {
    echo "Brrr… Ik trek mijn muts en winterjas aan";
}
treyBake
  • 6,440
  • 6
  • 26
  • 57
Gary5711
  • 1
  • 3
  • what do you mean the dutch message? I'm seeing 3 Dutch statements - what's explicitly your desired output? – treyBake Feb 26 '19 at 14:05
  • 3
    ^^ ah good point, else has no `()` it should just be `} else {//code` – treyBake Feb 26 '19 at 14:06
  • 1
    What happens when the `temparatuur` is `10`? – JNevill Feb 26 '19 at 14:06
  • Yes it is. I just want those messages to show if the condition has been met, it really isn't that hard to comprehend. lol – Gary5711 Feb 26 '19 at 14:07
  • You're missing a ';' after the first line and 'else' statements don't get conditions. – Russ J Feb 26 '19 at 14:08
  • 2
    @Gary5711 unfortunately, it is. It may seem clear to you, but that's because you know the issue. StackOverflow aren't mindreaders, you need to talk in absolutes – treyBake Feb 26 '19 at 14:08

1 Answers1

1

First of all you forgot semicolon

$temperatuur = 19; <--here

if ($temperatuur > 20) {
    echo "Vandaag is het lekker warm. Namelijk 23 graden";
}

elseif ($temperatuur > 10) {
    echo "Het is weer om een dun jasje aan te trekken";
}

else { //<-- else statement does not accept parameter
    echo "Brrr… Ik trek mijn muts en winterjas aan";
}

try this

Amanda
  • 58
  • 8
  • 1
    although this is an issue - typos should be flagged not answered :) – treyBake Feb 26 '19 at 14:06
  • That code's the one. Thank you Amanda. – Gary5711 Feb 26 '19 at 14:10
  • @treyBake this answer is good, because the OP's logic was a bit flawed, not just typos, but the if else statements as well. – Kebab Programmer Feb 26 '19 at 14:11
  • @Gary5711 can you please tick this answer as a correct? lol – Amanda Feb 26 '19 at 14:11
  • @Amanda good job!! – Kebab Programmer Feb 26 '19 at 14:11
  • @Gary5711 to tag someone in a comment do @ username (no space) :) and this is kinda what I do... it's called flagging things in SO that aren't in it's best practice. It helps keeps SO clean :) – treyBake Feb 26 '19 at 14:12
  • @KebabProgrammer it wasn't a flaw in the logic - it was invalid syntax, hence it's a typo/can't be reproduced – treyBake Feb 26 '19 at 14:12
  • @Gary5711 then don't come to SO for help for a typo – treyBake Feb 26 '19 at 14:27
  • @treyBake Or don't click on this topic if you can't answer it appropriately? Otherside of the spectrum. Really isn't that hard, innit? – Gary5711 Feb 26 '19 at 14:33
  • @Gary5711 I have 5+ years professional experience in PHP. All you had to do was read the manual and read the error message- then you'd actually fix it yourself. – treyBake Feb 26 '19 at 14:34
  • @treyBake Good for you. Which manual are you even on about? It's a deep dive. I've stated so, I had no idea how this even worked. I've gotten SO as a cheatsite for if I couldn't figure out what to do, so I did. What are you even on about? – Gary5711 Feb 26 '19 at 14:37
  • https://php.net <-the official manual. Just read the section on conditional statements. Well that's not what it's for .. SO is not a cheatsite that does your homework for you. – treyBake Feb 26 '19 at 14:37
  • No, it's a cheatsite in the way that it can help you and explain to you what you've done wrong and help you better yourself, like W3S, etc. Not bash and threaten you because it apparently was a syntax error I was not aware of. Stop being ignorant to your ignorance. – Gary5711 Feb 26 '19 at 14:43
  • @Gary5711 if by W3S you mean W3schools - then avoid w3schools, it's full of bad code and bad practice. The PHP section on that site especially is horrific. If you weren't aware of it, then you didn't read the error message. That's not my issue, but yours. – treyBake Feb 26 '19 at 14:47
  • Grats. @treyBake – Gary5711 Feb 28 '19 at 12:59