|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-01-28 21:09 UTC] yohgaki@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 06:00:02 2025 UTC |
Providing default values for fields, I find myself using the following syntax a lot: $a = $result->f('asd'); if (!$a) $a = 'nothing'; $a = ($result->f('asd') ? $result->f('asd') : 'nothing'); Generally: $a = ($x ? $x : $y); It would be handy to have a shorthand for this that would easy typing, legibility, and avoid duplicate evaluation of $x. Proposed syntax (not fussy) $x ?: $y i.e. if 'value if true' is empty, use 'condition value'.