|
| ||||||||||
| Tags: else, else if, php, programming language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to use Else and Else If Statement in PHP?
I have studied the different statements that are used in programming language, but I have never use the statements in PHP. So thought to take some tips from you guys so that I can use that statements in PHP also. Please tell me how to use Else and Else If Statement in PHP? Also provide me some sample of coding, so that I can understand it more clearly. ![]() |
|
#2
| ||||
| ||||
| Re: How to use Else and Else If Statement in PHP?
In many cases, you want to execute a statement if a condition is met, and another statement if the condition is not met. This is what else is. Else runs an if and executes instructions corresponding to the case where the if expression is FALSE. Conditional statements are used to perform different actions based on different conditions.
__________________ 3.2 (northwood) 2gig ramATI AIW X800xt 256mb Gigabyte GA-8knxp 875p Chipset Optiwrite 8X DVD Burner Win XP PRO Sp2 (Works Perfectly) 2 SATA Raptor 74gig Raid 0 2 7200 IDE 320gig HD |
|
#3
| |||
| |||
| Re: How to use Else and Else If Statement in PHP?
I am providing you with an example so that you can understand the concept of else statement : PHP Code: |
|
#4
| ||||
| ||||
| Re: How to use Else and Else If Statement in PHP?
Instructions after the else are executed if the if expression is FALSE, and if not followed by the expression elseif - only if they evaluated to FALSE. elseif, as its name suggests, is a combination of if and else. Like else, it allows to execute a statement after an if in case the original if expression evaluates to FALSE. But, unlike else, it will execute the instruction that if the elseif conditional expression evaluates to TRUE.
__________________ "When they give you ruled paper, write the other way..." J.R.J. |
|
#5
| ||||
| ||||
| Re: How to use Else and Else If Statement in PHP?
You can have multiple elseif which follow one after the other after an if statement. Elseif The first to be evaluated to TRUE would be executed. In PHP, you can also write 'else if' in both words and behavior will be identical to the version in one word. The syntactic meaning is slightly different, but ultimately, the result will be exactly the same. Elseif expression is only executed if the preceding if and any preceding elseif expressions evaluated to FALSE, and elseif expression evaluated to TRUE. |
|
#6
| |||
| |||
| Re: How to use Else and Else If Statement in PHP?
The following is an example of Else If statement, : PHP Code: |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to use Else and Else If Statement in PHP?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SQL statement problem in C# | AMISH | Software Development | 4 | 01-06-2010 01:17 PM |
| How to use If statement in PHP? | Deabelos | Software Development | 4 | 09-02-2010 05:14 AM |
| HTML if else statement | Darthmouth | Software Development | 3 | 02-09-2009 06:02 PM |
| If Statement in HTML | Beatrisa | Software Development | 3 | 07-08-2009 02:33 PM |
| What is the difference between while statement & do statement? | Athos | Software Development | 4 | 25-02-2009 07:52 PM |