Filed Under: General

Retrieve a page and save it in a variable with fopen.

5 May 2008 No Comment Tags: , ,

Today I have found this little snippet to retrieve a page to save it in a variable e.g. $content.

$handle = fopen($location, "r");
if($handle) { $contents = '';
while (!feof($handle)) { $contents .= fread($handle, 8192); }
fclose($handle);

You want to know what the 8192 does? It’s the byte data the browser retrieves before saving it into $contents.







Like our posts? Then subscribe via Mail:

Email:  

Similar Posts:

Socialize:

delicious stumbleupon

Leave your response!

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.com.