note 21414 added to function.isset

From: Date: Sun, 12 May 2002 03:35:57 +0000
Subject: note 21414 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-30497@lists.php.net to get a copy of this message
When coding with error_reporting( E_ALL ) (as all of you should strongly consider), using the ternary operator can be useful. Normally, I avoid it but here it seems to save space and be easy to recognize. $var = isset($var) ? $var : "new value"; as opposed to: if ( !isset( $var) ) { $var = "new value"; } This checks to see if a variable exists. If it exists, it does nothing. If it doesn't exist, it creates it with "new value" as the initial value. This can save space when verifying multiple variables (like from a form) while still being easily readable. -- http://www.php.net/manual/en/function.isset.php http://master.php.net/manage/user-notes.php?action=edit+21414 http://master.php.net/manage/user-notes.php?action=delete+21414 http://master.php.net/manage/user-notes.php?action=reject+21414

« previous php.notes (#30497) next »