in reply to Syntax for 1 line "either this or this"
$myVar = $somevalue || 'default';
Technically, it's not quite the same as the previous statements, but I'd say it is more commonly used than the trinary form.
There's whether something exists, whether it is defined (has a value different from undef), whether it has a "true" value (anything but undef or '' or 0 or '0'), and whether it's a reference or a non-referential scalar.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Syntax for 1 line "either this or this"
by parv (Parson) on May 30, 2003 at 06:54 UTC |