Wednesday, February 11, 2015

Use of at sign (@) in PHP

In PHP sometimes you seen @ sign in your code or some CMS or e-commerce coding than first time see that sign every one thought common question is what is use of that symbol in PHP?
Generally @ symbol use for email and when you see that in PHP coding without email than you Surprised is that use in code?Yes, this is use in PHP.This is called error control operator.It is error suppression operator in PHP.

What is use of @ symbol ?

In PHP at sign is use for stop any error or run code without display an error than just put @ sign in code before any PHP function.
Generally for Database connect every one use `mysql_connect()` function but when you use PHP version higher than 5.4 than it's display error even if you enter complate connection data with username and password than just put @ at the start of mysql_connect function like `@mysql_connect()` that connection make complete.
You can use @ symbol  some other functions also like `move_uploaded_files`,`get_file_contents`,`file_get_contents`,`file`,`include`,etc..

Please note than @ sign make your page slower and this only stop E_NOTICE errors not stop E_WARNING and E_ERROR types errors.

No comments :

Post a Comment