Basically, I've seen people using @
before their function calls, not for every function, but for some kind of extension functions like file_get_contents()
, mysql_connect()
and so on.
And yes, the question is: For what purpose are there these @
s before function calls?
Or in other words, what is the difference between @file_get_contents()
and file_get_contents()
?
A function is a piece of code that takes another input in the form of a parameter, processes it, and then returns a value. A PHP Function feature is a piece of code that can be used over and over again and accepts argument lists as input, and returns a value. PHP comes with thousands of built-in features.
Method is actually a function used in the context of a class/object. When you create a function outside of a class/object, you can call it a function but when you create a function inside a class, you can call it a method.
Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$ . Tip. See also the Userland Naming Guide.
@ is an error control operator. Basically it's suppressing errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With