Search code examples
phptimeoutget-headers

How to set timeout for get_meta_tags() & get_headers()


I've been using the get_meta_tags() & get_headers() PHP functions, and need to set a timeout value in case the website is slow or unresponsive. Does anyone know how to do it?


Solution

  • You should be able to influence this (as it's via URL wrappers) with the default_socket_timeout ini setting.

    Try either setting it in the php.ini file or by doing something like

    ini_set('default_socket_timeout', 10);
    

    to set a 10 sec timeout (the default value is 60)