Q:

file_get_contents() not working in yahoo host

i an displaying live stock quotes using $data = file_get_contents("http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv"); but i am using yahoo host. it doesnot allowing allow_url to change even not uploading .htaccess file. so how can i display live stock quotes in my webste.

A:

<?php 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec();
curl_close($ch);
?>

Use cURL :) Much better!

