Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP functions and @functions

Tags:

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()?

like image 942
tomsseisums Avatar asked Oct 21 '10 06:10

tomsseisums


People also ask

What are PHP functions?

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.

WHAT IS function and method in PHP?

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.

What is PHP function name?

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.


1 Answers

@ is an error control operator. Basically it's suppressing errors.

like image 145
fabrik Avatar answered Sep 20 '22 14:09

fabrik