Jump to content

Recommended Posts

normally the @ symbol precludes a line of code to avoid any errors even if the line would normally return a problem.

I've never seen it at the end of a statement like you had it.

 

ok i remove that it was a joke but seems like its not for you

well i just want an opinion why do you have to use it you know prevention is always better then cure 

Well, in some cases you may want to handle the error your own way. There are times where certain PHP functions don't throw Exceptions in PHP when they fail, but rather, result in a fatal error, bringing everything to an ugly halt. Like some of the Image functions.

 

Instead, I'd prefer to suppress the error, and check to see if an error actually occured, then throw an exception and handle it gracefully.

 

Error Control Operators
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. 

If the track_errors feature is enabled, any error message generated by the expression will be saved in the variable $php_errormsg. This variable will be overwritten on each error, so check early if you want to use it. 



<?php
/* Intentional file error */
$my_file = @file ('non_existent_file') or
    die ("Failed opening file: error was '$php_errormsg'");

// this works for any expression, not just functions:
$value = @$cache[$key]; 
// will not issue a notice if the index $key doesn't exist.

?>  

any idea about this

 

@mysql_query('select here ......');

 

can you give me some reason why do you put that @ there instead of filtering completely the code hhmmm

 

again for those who use this @@ lay me your idea

 

Error display on your site could cause it to get hack.

 

this answer sounds a little interesting

It will just hide the error from showing to other people, example

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in...

 

If you read about SQL Injection, hackers can make use of error display like telling them which table is not exist and which is exist to inject your database.

i know what is @ for but im asking for the reason why do people use it like i said i only want an idea about this no wrong and correct answer

 

my idea of using @ is that the code is not perfect meaning you are expecting some error

so i want to know why do this people use this instead of filtering properly the code

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.