On 30 June 2006 13:37, tedd wrote: > At 11:07 PM -0600 6/29/06, John Meyer wrote: > > Larry Garfield wrote: > > > > > > switch is fine if your elseif comparisons are equality > based. If they're not equality based, then they don't map to > switch as well. > > > > In other words, if you look at a logical ladder as the roots > of the tree, as long as each root has the same number of > forks (say each fork ends only one way), your fine with a > switch. If you have one, however, that has only one > condition, and another that has two, then you need an > if...elseif logic tree. > > Interesting -- can you give me an example? How about this -- a paraphrase of which occurs in many of my scripts: if (isset($_POST['id'])): $id = $_POST['id']; // etc. -- other initializations based on $id elseif ($_POST['action']=='add'): $id = generate_id(); // initialize stuff to empty values elseif (potential_other_test_to_detect_other_valid_states()): // other stuff else: KaBlooie(); endif; Of course, that *could* still be implemented using the switch(TRUE) technique (and I've used that elsewhere), but in a case like this instance I prefer the if/elseif construct. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php