linux1880 Posted October 22, 2009 Share Posted October 22, 2009 Dear friends can anyone give me example of what scenario we use nested if Thank you Quote Link to comment Share on other sites More sharing options...
cags Posted October 22, 2009 Share Posted October 22, 2009 Thats a little vague. Nested if's are just if statments inside each other so you would use them anywhere you need to split information down further. As an example... Let's say we have a group of people and we wanted to bahave differently dependent on gender and marital status. $name = "john"; $gender = "male"; $married = TRUE; if($gender == "male") { if($married) { echo "Hello 'Condemned Man' $name"; } else { echo "Hello Mr $name"; } } elseif($gender == "female") { if($married) { echo "Hello Mrs $name"; } else { echo "Hello Miss $name"; } } else { "Hello Ladyboy $name"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.