Error trapping getaddrinfo - File not found v. Temporary failure in name resolution?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kronalias

    Error trapping getaddrinfo - File not found v. Temporary failure in name resolution?

    Hi - could a guru please help?

    I'm trying to trap errors when I try to load a url into an array. I can
    trap all errors by using this code:

    if ( @file($url) == false ){
    got a problem;
    }

    .... but then I don't know whether the problem is that the url file
    doesn't exist, or whether it's just a temporary failure in name
    resolution.

    1. Is there a way to find out what the problem is?

    2. I apologise for this question, and my only defence is that I'm a
    newbie! Could someone please explain what the '@' in my code above
    does? I've been rtfming and googling until I'm blue in the face, but I
    can't figure it out...

    Thanks in advance for not yelling at me...

    Regards, Kronalias

  • petersprc

    #2
    Re: Error trapping getaddrinfo - File not found v. Temporary failure in name resolution?

    You can probably see what the problem is by setting
    error_reporting (E_ALL) and removing the @ sign which is used to
    suppress error messages. More info on the error suppression operator:



    Kronalias wrote:
    Hi - could a guru please help?
    >
    I'm trying to trap errors when I try to load a url into an array. I can
    trap all errors by using this code:
    >
    if ( @file($url) == false ){
    got a problem;
    }
    >
    ... but then I don't know whether the problem is that the url file
    doesn't exist, or whether it's just a temporary failure in name
    resolution.
    >
    1. Is there a way to find out what the problem is?
    >
    2. I apologise for this question, and my only defence is that I'm a
    newbie! Could someone please explain what the '@' in my code above
    does? I've been rtfming and googling until I'm blue in the face, but I
    can't figure it out...
    >
    Thanks in advance for not yelling at me...
    >
    Regards, Kronalias

    Comment

    • Kronalias

      #3
      Re: Error trapping getaddrinfo - File not found v. Temporary failure in name resolution?

      That's just what I was after - thanks v much Peter!

      Comment

      Working...