PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY (My web site) Confusion

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Confusion alert: I mentioned earlier that statements must always be followed by a semi- colon. This applies only to the statements (or commands) inside the curly braces. Although called a conditional statement, this decision-making pattern is one of PHP s control structures, and it shouldn t be followed by a semicolon. Think of the semicolon as a command that means do it. The curly braces surround the command statements and keep them together as a group. The code inside the curly braces is executed only if the condition is true. If it s false, PHP ignores everything between the braces and moves on to the next section of code. How PHP determines whether a condition is true or false is described in the following section. Sometimes, the if statement is all you need, but you often want a default action to be invoked. To do this, use else, like this: if (condition is true) { // code to be executed if condition is true } else { // default code to run if condition is false } What if you want more alternatives? One way is to add more if statements. PHP will test them, and as long as you finish with else, at least one block of code will run. However, it s important to realize that all if statements will be tested, and the code will be run in every single one where the condition equates to true. If you want only one code block to be executed, use elseif like this: if (condition is true) { // code to be executed if first condition is true } elseif (second condition is true) { // code to be executed if first condition fails // but second condition is true else { // default code to run if both conditions are false } You can use as many elseif clauses in a conditional statement as you like. It s important to note that only the first one that equates to true will be executed; all others will be ignored, even if they re also true. This means you need to build conditional statements in the order of priority that you want them to be evaluated. It s strictly a first-come, first- served hierarchy. Although elseifis normally written as one word, you can use else ifas separate words.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Leave a Reply