note 84195 added to function.isset

From: Date: Wed, 02 Jul 2008 20:34:13 +0000
Subject: note 84195 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-141087@lists.php.net to get a copy of this message
It is possible to encapsulate isset() calls inside your own functions if you pass them by reference (note the ampersand in the argument list) instead of by value. A prime example would be the heavily-requested "ifsetor" function, which will return a value when it is set, otherwise a default value that the user specifies is used. <?php function ifsetor(&$val, $default = null) { return isset($val) ? $val : $default; } // example usage $id = intval(ifsetor($_GET['id'], 0)); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 66.170.10.66 ---- Manual Page -- http://www.php.net/manual/en/function.isset.php Edit -- https://master.php.net/note/edit/84195 Del: integrated -- https://master.php.net/note/delete/84195/integrated Del: useless -- https://master.php.net/note/delete/84195/useless Del: bad code -- https://master.php.net/note/delete/84195/bad+code Del: spam -- https://master.php.net/note/delete/84195/spam Del: non-english -- https://master.php.net/note/delete/84195/non-english Del: in docs -- https://master.php.net/note/delete/84195/in+docs Del: other reasons-- https://master.php.net/note/delete/84195 Reject -- https://master.php.net/note/reject/84195 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141087) next »