Jump to content

Recommended Posts

I know this is a simple question, that if I knew what it was technically called i could probably look up and find the answer for myself. However, I don't know what its called, and of all the books I have none of them mention or use this.

 

Anyway in my searches from time to time when i'm stuck on something looking for samples or more information on particular functions in php I come across something some has done for an example that has "@" in front of it or something similar, usually "@". Why is that used, what does it signify? and is there other characters used in a similar fashion to when someone uses "@".

 

So all in all I am curious. I just want to know what it is, what it does, if theres any specific doc on the use of "@" and or similar characters.

Link to comment
https://forums.phpfreaks.com/topic/186376-simple-question/
Share on other sites

And don't use the @ in your code anyway. Due to the poor way that this was implemented, just having it present in your code causes the following internal code to occur, even when no error is present -

$some_temp_var = error_reporting(0); // get current error_reporting level and temporarily set it to zero
statement_that_has_the_@_in_front_of_it;
error_reporting($some_temp_var); // restore error_reporting to previous level

 

You should in fact always have error_reporting set to at least E_ALL so that all detected errors are 'reported'. On a development system you should have display_errors set to ON (you want to see what errors are occurring so that that php helps you during the development process by pointing out problems it detects when your code executes.) On a live server you should have display_errors set to OFF and log_errors set to ON (you don't want to display any unexpected errors, but you do want to log them so that you have a record of what (and when something) is occurring, like a legitimate visitor (or a hacker) entering unexpected data that your validation logic does not catch and cause your script to generate a php error.)

 

By correctly managing the display_errors setting (and of course writing and testing your code so that it is as error free as possible and by properly validating  data) there is absolutely no reason to put an @ in your scripts.

 

 

Link to comment
https://forums.phpfreaks.com/topic/186376-simple-question/#findComment-984213
Share on other sites

Thank you, thank you all. Like I said I was just curious about it, I never used it before, I see it from time to time pop up in source examples. Then I noticed one of the people I am coding with on a project using it, to the say the least that is ultimately what sparked my curiosity.

 

Also explains why none of my books have ever touched on it, grant it I don't use them anymore but I remember when I did read through them some time ago. Just had me thinking, is this something I need to use for somethings, lemme find out, and I did.

 

Again thank you

Link to comment
https://forums.phpfreaks.com/topic/186376-simple-question/#findComment-984260
Share on other sites

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.