Lays out the form of an if statement.
The form of an if statement.
The if statement executes a statement if the expression inside the parentheses evaluates to true; otherwise the code is skipped. It may be a single statement followed by a semicolon. Usually it's a compound statement surrounded by curly braces. An else statement may appear immediately after the statement and has a statement of its own. It, too, may be either single or compound. It is executed only when the previous expression is false. In between an if statement and an else statement you may put as many elseif statements as you'd like. Each elseif expression is evaluated in turn, and control skips past those that are false. If an elseif statement evaluates to true, then the rest of the code in the greater if statement is skipped. That is to say, only one match will be made.demonstrates an if-else statement.
Of course, you are not obligated to have an elseif or an else. Sometimes you mightwant to build a very simple if statement.You can use if to build a series of checks that covers all possible cases. Just start by checking for the first condition with an if; then check for each following condition with an elseif. If you put an else at the end, you will have accounted for all possible cases. uses this method to print the day of the week in German. The script gets today's name and then compares it to the days Monday through Saturday. If none of these match, it is assumed to be Sunday.
An if-elseif-else Statement<?
A Simple if Statement<?
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.