note 119693 added to language.operators.errorcontrol
| From: | dkellner | Date: | Thu, 04 Aug 2016 10:21:59 +0000 |
| Subject: | note 119693 added to language.operators.errorcontrol | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206208@lists.php.net to get a copy of this message | ||
There is no reason to NOT use something just because "it can be misused". You could as
well say "unlink is evil, you can delete files with it so don't ever use unlink".
It's a valid point that the @ operator hides all errors - so my rule of thumb is: use it only
if you're aware of all possible errors your expression can throw AND you consider all of them
irrelevant.
A simple example is
<?php
$x = @$a["name"];
?>
There are only 2 possible problems here: a missing variable or a missing index. If you're sure
you're fine with both cases, you're good to go. And again: suppressing errors is not a
crime. Not knowing when it's safe to suppress them is definitely worse.
----
Server IP: 72.52.91.14
Probable Submitter: 195.56.247.34
----
Manual Page -- http://php.net/manual/en/language.operators.errorcontrol.php
Edit -- https://master.php.net/note/edit/119693
Del: integrated -- https://master.php.net/note/delete/119693/integrated
Del: useless -- https://master.php.net/note/delete/119693/useless
Del: bad code -- https://master.php.net/note/delete/119693/bad+code
Del: spam -- https://master.php.net/note/delete/119693/spam
Del: non-english -- https://master.php.net/note/delete/119693/non-english
Del: in docs -- https://master.php.net/note/delete/119693/in+docs
Del: other reasons-- https://master.php.net/note/delete/119693
Reject -- https://master.php.net/note/reject/119693
Search -- https://master.php.net/manage/user-notes.php