note 82472 added to control-structures.else
| From: | dormeydo at gmail dot com | Date: | Sat, 12 Apr 2008 11:51:01 +0000 |
| Subject: | note 82472 added to control-structures.else | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138231@lists.php.net to get a copy of this message | ||
An alternative and very useful syntax is the following one:
statement ? execute if true : execute if false
Ths is very usefull for dynamic outout inside strings, for example:
print('$a is ' . ($a > $b ? 'bigger than' : ($a == $b ? 'equal to'
: 'smaler than' )) . ' $b');
This will print "$a is smaler than $b" is $b is bigger than $a, "$a is bigger than
$b" if $a si bigger and "$a is equal to $b" if they are same.
----
Server IP: 212.63.193.10
Probable Submitter: 130.240.203.137
----
Manual Page -- http://www.php.net/manual/en/control-structures.else.php
Edit -- https://master.php.net/note/edit/82472
Del: integrated -- https://master.php.net/note/delete/82472/integrated
Del: useless -- https://master.php.net/note/delete/82472/useless
Del: bad code -- https://master.php.net/note/delete/82472/bad+code
Del: spam -- https://master.php.net/note/delete/82472/spam
Del: non-english -- https://master.php.net/note/delete/82472/non-english
Del: in docs -- https://master.php.net/note/delete/82472/in+docs
Del: other reasons-- https://master.php.net/note/delete/82472
Reject -- https://master.php.net/note/reject/82472
Search -- https://master.php.net/manage/user-notes.php