Jump to content

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/6008-mail/#findComment-21568
Share on other sites

[!--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?
Link to comment
https://forums.phpfreaks.com/topic/6008-mail/#findComment-21581
Share on other sites

[!--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 URL

how would you do it on a function

would you still do or die(php_error) lol
i am not too sure
Link to comment
https://forums.phpfreaks.com/topic/6008-mail/#findComment-21586
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/6008-mail/#findComment-21590
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/6008-mail/#findComment-21862
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.