Hi,
the else if is valid in this case.
I think the problem is with the heredoc syntax.
printgreeting();
function printgreeting(){
global $guess, $nopetals;
if (empty($guess)) {
print"<h2>Welcome to Petals Game</h2>";
} else if ($guess==$nopetals) {
print"<h2>You Got it Rite</h2>";
} else {
print <<<HERE
Sorry wrong guess,<br>
your guess was $guess <br>
but no. of petals is $nopetals.<br>
HERE;
}
}
Additionally, there mustn't be any whitespaces at the end of the lines print <<<HERE and HERE;
You'll get an error message otherwise.
Generally: no empty whitespaces and the closing tag (HERE; in this case) must be at the very beginning of a line and there mustn't be any other characters at the end of the line (like the } in your case).
Thomas