I am following good programming practices and I am logging the PHP errors to file instead of displaying it to user. I use set_error_handler()
for that.
Now the problem. For example, I have somewhere:
@file_exists('/some/file/that/is/outside/openbasedir.txt');
But despite the error suppression operator, the error message logs. I don't want that. I want suppressed errors not to pass to my error handler.
@
. Its a good sign, that you did something wrong and dont't want to fix it. However, the errorhandler-callback gets called, even if the statement itself is "silenced" via@
. – Henshaw@$a
is acceptable instead ofisset($a)?$a:''
. The code readability overweights the "disadvantages". – Apoplexy@
hide errors, but they are still generated, formatted, error handlers are called, etc. Just structure your code so that you don't have to use isset() much. – BeltBAD PRACTICE
and you should stop doing it – Politicoerror_reporting()
. The@
operator really has no place in good code. – Delanieisset()
tells me, that you definitely do something wrong: Intialize your local variables! – HenshawWarning: file_exists(): open_basedir restriction in effect. File(/some/path) is not within the allowed path(s):
, if you know how to avoid this warning without @ operator, please assist. – Apoplexy@
can occur in a third-party code. It is used in Yii2 for instance. So you can still have it even if you don't use it.@
being the bad practice is unrelated to the question. – Cohleen