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

rob picture rob · May 18, 2011 · Viewed 11.7k times · Source

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?

Answer

James C picture James C · May 18, 2011

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)