any alternative of file_get_contents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arctushar
Forum Newbie
Posts: 5
Joined: Mon Aug 31, 2009 10:48 am

any alternative of file_get_contents

Post 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>";
_64k
Forum Newbie
Posts: 16
Joined: Thu Nov 12, 2009 8:52 am

Re: any alternative of file_get_contents

Post 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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: any alternative of file_get_contents

Post 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
_64k
Forum Newbie
Posts: 16
Joined: Thu Nov 12, 2009 8:52 am

Re: any alternative of file_get_contents

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: any alternative of file_get_contents

Post by John Cartwright »

It comes with the installation, however, it is not enabled by default.
Post Reply