"On Error Resume Next" in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

"On Error Resume Next" in PHP?

Post 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

Code: Select all

On Error Resume Next
in ASP?

Have A Nice Day!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

put an @ sign in front of the function call you expect to fail.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post 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.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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 :roll:
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

"On Error Resume Next" is a poor kind of approximation to try{}catch(){}
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

Ok, thanks for posts. Really appreciated!!! ;)
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

In a loop, the continue and break keywords can also be used for further checking.
Post Reply