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 Link to comment https://forums.phpfreaks.com/topic/178669-when-to-use-nested-if/ 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"; } Link to comment https://forums.phpfreaks.com/topic/178669-when-to-use-nested-if/#findComment-942461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.