Given that there is no speed difference between using braces and not using braces, it's usually down to a readability issue. If you only have one line of code to execute, you can do without the braces entirely. The downside of this system is that the $Age variable needs to be checked repeatedly. else else part if any will be taken for execution while if returns false. if Block will be taken for execution while true. You could reach the same effect by having lots of if statements, however this is a slightly neater way of doing things. And, the list of PHP constructs and syntax with the combination of if, else keywords are as follows. This means you can, for example, check whether a variable is set and whether it is set to a certain value - if the variable is not set, PHP will short-circuit the if statement and not check its value, which is good because if you check the value of an unset variable, PHP will flag an error!Ī helpful addition to if statements is the elseif statement, which allows you to chain commands together in a slightly more intelligent way. If ($Age > 10
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |