Re: note 9796 added to Alternative syntax for control structures
| From: | J. M. Castagnetto | Date: | Sat, 25 Nov 2000 07:40:52 +0000 |
| Subject: | Re: note 9796 added to Alternative syntax for control structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8128@lists.php.net to get a copy of this message | ||
Do use a sane email address next time, or add a
"NOSPAM" somewhere in it.
The ternary operator is not a control structure. See
the description in the "Comparison operators" section.
Your note will be removed.
--- TButzon@php2.chek.com, at@php2.chek.com,
ImAWebDesigner.com@php2.chek.com wrote:
> I vaguely remember seeing this somewhere, but it
> very well could've been in a Perl reference, too.
>
> There's an alternate if construct that I couldn't
> find in the manual here - it's very useful if you
> want to test a condition mid-statement and don't
> want to break the statement for the condition.
> Here's the syntax:
> (condition) ? result if true : result if false
>
> For example, let's say you're adding a record to a
> database; if the user gave their email address, you
> want it to be added in parenthesis in the same field
> as the name. Assume $name already contains the
> user's name, and $email may or may not contain the
> user's email address.
>
> // Add email to name if present
> $name = $name . ((isset($name)) ? (" (" . $email .
> ")") : "");
>
>
>
http://www.php.net/manual/control-structures.alternative-syntax.php
>
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-notes-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-notes-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/