Im new to PHP, and I am learning about control structures. I just learned about if statements, switch statement and while loops. I know the syntax for an if statement is:
if (condition)
{
//code to be executed if the condition is true;
}
switch syntax:
switch (expression)
{
case 1:
//code to be executed;
break;
case 2:
//code to be executed;
break;
default:
//code to be executed;
}
and the syntax for a while loop is:
while (expression)
{
//code to be executed if the expression is true;
}
I see the terms condition and argument and expression pretty interchangeably. Do they all mean the same thing? If not what are the differences?
I would use this terminology:
That said, some people will refer to the condition of a while loop as an argument, for example. In my opinion this isn’t the best terminology, because an argument is something passed to a function, and if/while/switch are not functions in PHP (they are in some languages).
But you’re right, some people will say “the argument of the while loop.” Just understand that they mean “the condition of the while loop.”