What does @ mean before you enable or require

I wonder what @ means when we use it before inclusion or request in php ?!

eg:

@include('block.php'); 

maybe this is a question about noob, but I need to know this guys ?!

so sorry that

+4
source share
3 answers

@ is a shut-up statement. If something goes wrong, an error message will not appear. This is usually bad practice; firstly, because error messages occur for a good reason, and secondly, because it ridiculously slows down what he does.

This is roughly equivalent to wrapping the operator in:

 $oldErrorLevel = error_reporting(0); // the statement error_reporting($oldErrorLevel); 

Here's a link to a PHP manual page that documents it.

+10
source

@ before calling the function suppresses any errors that the function usually displays.

In the case of include person doing this wants the script to continue to work if block.php not. The best way to do this is to usually do something like this:

 if(is_readable('block.php')) { include('block.php'); } 
+3
source

@ is an error suppression operator in php, you will not see any error if the file is not found in this expression.

0
source

Source: https://habr.com/ru/post/1308077/


All Articles