note 84195 deleted from function.isset by cmb

From: Date: Sun, 10 Feb 2019 11:29:34 +0000
Subject: note 84195 deleted from function.isset by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210221@lists.php.net to get a copy of this message
Note Submitter: soapergem at gmail dot com ---- 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)); ?>

« previous php.notes (#210221) next »