Page 1 of 1
any alternative of file_get_contents
Posted: Sat May 22, 2010 8:20 pm
by arctushar
I used the below codes. but it does'nt return anything. is there any alternative? plz help me
Code: Select all
$googleurl="http://www.google.com/search?q=define:bios";
$file = file_get_contents($googleurl);
$define0=explode("<ul",$file);
$define1=explode("ul>",$define0[1]);
echo "<ul".$define1[0]."ul>";
Re: any alternative of file_get_contents
Posted: Sun May 23, 2010 9:06 am
by _64k
Code: Select all
$googleurl="http://www.google.com/search?q=define:bios";
$file = file_get_contents($googleurl);
The above code works, it will return the content of the file requested. Are you getting any errors?
an alternative to file_get_contents is curl. However curl is not a built in function like file_get_contents, it will require pear to install it. Curl does have advantages for example to ability to post.
Re: any alternative of file_get_contents
Posted: Sun May 23, 2010 9:09 am
by Eran
it will require pear to install it
cURL is a PECL extension. Pear is something different (a library of classes). And cURL comes built in with the standard PHP installation
Re: any alternative of file_get_contents
Posted: Sun May 23, 2010 10:31 am
by _64k
cURL is a PECL extension. Pear is something different (a library of classes). And cURL comes built in with the standard PHP installation
oops, cheers pytrin, although on ubuntu linux, after installin php I have to install cURL using sudo apt-get install php5-curl, so arctushar might want to note that it may not 'just work' with the standard installation on all platforms.
Re: any alternative of file_get_contents
Posted: Sun May 23, 2010 10:44 am
by John Cartwright
It comes with the installation, however, it is not enabled by default.