> -----Original Message----- > From: adrian GREEMAN > [mailto:[EMAIL PROTECTED] > Sent: 11 June 2003 15:23 > > I am confused by the shorthand "if" notation. > For example I just saw this PHP snippet on another forum > > <? > $bkgndClass = $bkgndClass == "darkBkgnd" ? "liteBkgnd" : > "darkBkgnd"; > } > ?> > > I think it is an if but cannot find it in the manual. How > is that written in the more normal notation - if(){} etc??
See http://uk.php.net/manual/en/language.operators.comparison.php where the ?: operator is explained. > [And please excuse a slightly off-thread but related extension to > the question but I have seen similar in Javascript - namely --- > var evt = (evt ? evt : ((window.event) ? window.event : null); > is this the same notation or something else?] Yes, same basic notation -- the only minor difference is that the associativity is different, so nested ?: operators are evaluated in a different order. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php