AV1611 Posted March 28, 2006 Share Posted March 28, 2006 Can someone tell me what the @ does when you put it in front of a function?i.e.mail()vs.@mail()Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/ Share on other sites More sharing options...
ober Posted March 28, 2006 Share Posted March 28, 2006 Error suppression. If the function errors out, it won't display anything to the user.The best way to use that is to set the function output equal to something and if it's not what you expect, you can append the error to a log file or email yourself and the user will never know the difference. You can also use it to display a "nice" error message to the user instead of the script spitting out what line the error came from and what the name of your file was, etc, etc. Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21568 Share on other sites More sharing options...
holowugz Posted March 28, 2006 Share Posted March 28, 2006 i THOUGHT @ supressed error message Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21571 Share on other sites More sharing options...
AV1611 Posted March 28, 2006 Author Share Posted March 28, 2006 thanks... maybe if I remove it from my script, it'll tell me why it quit working LOL Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21572 Share on other sites More sharing options...
ober Posted March 28, 2006 Share Posted March 28, 2006 That's very true! Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21573 Share on other sites More sharing options...
holowugz Posted March 28, 2006 Share Posted March 28, 2006 [!--quoteo(post=359267:date=Mar 28 2006, 02:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 28 2006, 02:56 PM) [snapback]359267[/snapback][/div][div class=\'quotemain\'][!--quotec--]Error suppression. If the function errors out, it won't display anything to the user.The best way to use that is to set the function output equal to something and if it's not what you expect, you can append the error to a log file or email yourself and the user will never know the difference. You can also use it to display a "nice" error message to the user instead of the script spitting out what line the error came from and what the name of your file was, etc, etc.[/quote]Just out of interest how would you make a custom error page come up if there is an error in the function? Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21581 Share on other sites More sharing options...
ober Posted March 28, 2006 Share Posted March 28, 2006 As long as the processing is all done before any output, you would redirect the user with the header() function. Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21583 Share on other sites More sharing options...
holowugz Posted March 28, 2006 Share Posted March 28, 2006 [!--quoteo(post=359282:date=Mar 28 2006, 03:09 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 28 2006, 03:09 PM) [snapback]359282[/snapback][/div][div class=\'quotemain\'][!--quotec--]As long as the processing is all done before any output, you would redirect the user with the header() function.[/quote]what i eamnt was on a MYSQL you can do like or die(mysql_error)or in place of that redirect it to another page and encode the error in the URLhow would you do it on a functionwould you still do or die(php_error) loli am not too sure Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21586 Share on other sites More sharing options...
ober Posted March 28, 2006 Share Posted March 28, 2006 No... you cannot run an "or die()" on a regular function. You just have to know what the output is supposed to be and if it isn't in that "range", you have to deal with it accordingly. Like I said, if you're processing before any output is created, you can redirect to another page and show some sort of error. If the processing or the running of the function is AFTER some output has been created, you'll just have to create your error message right there. Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21590 Share on other sites More sharing options...
holowugz Posted March 28, 2006 Share Posted March 28, 2006 Oh i see, Ok fair enough ty very much Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21603 Share on other sites More sharing options...
txmedic03 Posted March 29, 2006 Share Posted March 29, 2006 There are ways to add error handling on your functions, but if you can help it don't use '@'. Don't hide your errors, fix them. In my years of PHP experience I have never had to use '@' to cover an error. I was always able to find a way to make everything work without suppressing errors. That's not to say that there are never situations where you might need the '@', just that they are not all that common. If every other line of your code is full of '@'s then you need to rethink your code a bit. Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21862 Share on other sites More sharing options...
AV1611 Posted March 29, 2006 Author Share Posted March 29, 2006 txmedic,I could not agree more...the code already had the @, I just didn't know what it was, I've never used it, and have written quite a bit of code to this point... Quote Link to comment https://forums.phpfreaks.com/topic/6008-mail/#findComment-21920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.