Page 1 of 1
"On Error Resume Next" in PHP?
Posted: Wed Nov 12, 2003 4:18 am
by mudkicker
Hi people,
I've something to ask and it's very important for me in my project.
Is there any function or code that works like
in ASP?
Have A Nice Day!
Posted: Wed Nov 12, 2003 4:57 am
by twigletmac
Forgive those of us that have no ASP experience but what exactly does on error resume next do and in what context.
Mac
Posted: Wed Nov 12, 2003 8:48 am
by hedge
put an @ sign in front of the function call you expect to fail.
Posted: Wed Nov 12, 2003 12:22 pm
by mudkicker
actually i don't know ASP so much I'm good at PHP but in the workplace my friends who is programming with ASP they are using this code. it ignores an error in the code and continues to execute.
Posted: Wed Nov 12, 2003 12:36 pm
by Gen-ik
"On error resume next" is also used by VBScript.
It's pretty simple to do in PHP....
Code: Select all
<?php
$result = @mail($to, $subject, $body, $headers);
// Use the following bit to do something if and error occured.
if(!$result)
{
// An error occured so do something
}
?>
I'm sure there's a global way of doing it though..... but I can't remember it

Posted: Wed Nov 12, 2003 12:45 pm
by scorphus
"On Error Resume Next" is a poor kind of approximation to try{}catch(){}
Posted: Wed Nov 12, 2003 1:31 pm
by JAM
As said, @function is the php way of 'error resume next' VBA style.
But don't do that. It will harm you more than serve you in the end (of course, if there isn't a very good reason for it). Just my 2cents.
Posted: Wed Nov 12, 2003 6:04 pm
by mudkicker
Ok, thanks for posts. Really appreciated!!!

Posted: Thu Nov 13, 2003 7:54 am
by EvilWalrus
In a loop, the continue and break keywords can also be used for further checking.