using stream_context_create() with the right options for timeout would be better than ini_set