note 85742 added to function.isset
| From: | mark dot fabrizio at gmail dot com | Date: | Tue, 16 Sep 2008 02:01:40 +0000 |
| Subject: | note 85742 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144433@lists.php.net to get a copy of this message | ||
I know this is probably not the recommended way to do this, but it seems to work fine for me.
Instead of the normal isset check to extract variables from arrays (like $_REQUEST), you can use the
@ prefix to squelch any errors.
For example, instead of:
<?php
$test = isset($_REQUEST['test']) ? $_REQUEST['test'] : null;
?>
you can use:
<?php
$test = @$_REQUEST['test'];
?>
It saves some typing, but doesn't give the opportunity to provide a default value. If
'test' is not an assigned key for $_REQUEST, the assigned value will be null.
----
Server IP: 209.41.74.194
Probable Submitter: 98.216.180.152
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit -- https://master.php.net/note/edit/85742
Del: integrated -- https://master.php.net/note/delete/85742/integrated
Del: useless -- https://master.php.net/note/delete/85742/useless
Del: bad code -- https://master.php.net/note/delete/85742/bad+code
Del: spam -- https://master.php.net/note/delete/85742/spam
Del: non-english -- https://master.php.net/note/delete/85742/non-english
Del: in docs -- https://master.php.net/note/delete/85742/in+docs
Del: other reasons-- https://master.php.net/note/delete/85742
Reject -- https://master.php.net/note/reject/85742
Search -- https://master.php.net/manage/user-notes.php