www.webdeveloper.com
Results 1 to 2 of 2

Thread: File_get_content displays error every time the URL doesn't exist

  1. #1
    Join Date
    Mar 2010
    Posts
    701

    File_get_content displays error every time the URL doesn't exist

    PHP Code:
            $d file_get_contents($url);
            
    //display error if site can't be loaded
            
    if (!$d) { 
                return 
    false;
            } 
    Instead of returning false for me to handle, it returns this error:
    Code:
    [phpBB Debug] PHP Notice: in file public_html/functions.php on line 3810: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known
    [phpBB Debug] PHP Notice: in file public_html/functions.php on line 3810: file_get_contents(http://a.com/) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
    How can I make it simply return false instead displaying this error?

  2. #2
    Join Date
    Oct 2005
    Location
    Cambridgeshire, UK
    Posts
    191
    What about this:

    PHP Code:
    if (!$d file_get_contents($url)) {
      return 
    false;

    Or turn error reporting off haha
    BIOSTALL.com
    - Freelancing Services
    - Web Development Snippets, Hints and Tips

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles