What is elseif statement


Not sure what an elseif statement also this is my first time using PHP.


If you have not studied JavaScript yet, then it would be advisable. The syntax is very similar and the interpreter a lot more forgiving. PHP does not tolerate ANY discrepancies and is syntactically very strict. Until you are comfortable with syntax, this is not the course to be in. Just saying...


An if statement is pretty straight forward:

    if ($flag) {
        return "Flag is set";

Then we have the else statement that we can use as a fall back (default branch)...

    if ($flag) {
        return "Flag is set";
    } else {
        return "Flag is not set";

The above is a binary` condtional branch: *either / or.

Sometimes we have a number of possible conditions, one of which may apply to the current state of a variable or expression. This is where elseif comes in.

if ($num < 0) {
    return "Number is negative";
elseif ($num > 0) {
    return "Number is positive";
} else {
    return "Number is zero";

As I understand it, we can write both, elseif and else if with the same effect and no excpetion thrown.

else if ($num > 1) {


Sorry the point no one is answering is that the lessons have missed a step, and now lesson 1 of Module 3 refers to ELSEIF - even though that's never been mentioned before.


Agreed. The lesson is asking the student to write an elseif statement, when that was not, in fact, covered in past lessons.


What are we supposed to do then with lesson 1 of module 3?

I happen to know a little about the ELSEIF statement but it isn't covered just like @amgabriel123 has stated.


Yep your lessons missed a step.

PHP Module 2 taught us about IF and ELSE statements. It never mentions anything about an ELSEIF statement.

And then in lesson 1 of Module 3 it tells us to practice what we learnt in the previous module by making an IF / ELSEIF / ELSE statement. But students can't do that if they were never taught about ELSEIF statements.


This is a reported issue, for the record. We needn't beleager the subject.


Oops sorry! didn't know.