file_get_contents super slow ...use curl?
Posted: Fri Jun 28, 2013 5:50 pm
So I'm grabbing some html tags from another site and the load times for file_get_contents is at least 8 seconds.
Here's what my function looks like
(query is submitted through user form)
I thought I was cool by adding in $context but it didn't change anything. Some articles online suggested switching to "curl"
tactics and I just wanted to know if that will really work. =)
Here's what my function looks like
(query is submitted through user form)
function getTitle($query) { $opts = array('https'=>array('header'=> 'Connection: close')); $context = stream_context_create($opts); $pattern = "/<title ?.*>(.*)<\/title>/"; preg_match($pattern, file_get_contents($query,false,$context), $matches); return $matches[1]; }The function works it just takes way too long.
I thought I was cool by adding in $context but it didn't change anything. Some articles online suggested switching to "curl"
tactics and I just wanted to know if that will really work. =)