Re: syntax question
| From: | Niels Andersen | Date: | Thu, 06 Mar 2003 13:34:12 +0000 |
| Subject: | Re: syntax question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138461@lists.php.net to get a copy of this message | ||
By the way, beware of possibly buggy code:
strpos() will return 0 if the string begins with '-', but it will return
FALSE if '-' is not found in the string.
Since both 0 and FALSE will evaluate to boolean false in your condition, you
may get weird results.
Use this instead: (strpos($a, '-') !== FALSE) ?
"Jimmy" <jtx@hatesville.com> wrote in message
news:000801c2e3c1$5f3fdf90$4500a8c0@theplague...
> I'm looking through some existing code for a project I'm working on, but
> I keep running into this syntax that I really don't understand. Here's
> an example:
>
> $a=strpos($a,'-')?explode('-',$a,2):array($a);
>
> What do the ? and the : do here? I'm seeing this sort of thing all over
> and just have no idea what ? : do. Thanks.
>
>