note 13020 modified in function.curl-exec by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:56:04 +0000 |
| Subject: | note 13020 modified in function.curl-exec by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80001@lists.php.net to get a copy of this message | ||
If you retrieve a web page and print it (so you can see it in your browser), and the page has an
expiration, this expiration now applies to MyProgram.php and next time your program/page is called,
even if it's grabbing a different web page, it will show what it just displayed. In Netscape
you can get rid of this by going into Edit, Options, Advanced, Cache, and clear out the Disk Cache.
But this is really annoying after short order. The following prevents the above scenario:
<?php
function GetCurlPage ($pageSpec) {
$ch = curl_init($pageSpec);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tmp = curl_exec ($ch);
curl_close ($ch);
// if you intend to print this page, better clear out expiration tag
$tmp = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i',
'', $tmp);
return $tmp;
}
?>
--was--
If you retrieve a web page and print it (so you can see it in your browser), and the page has an
expiration, this expiration now applies to MyProgram.php and next time your program/page is called,
even if it's grabbing a different web page, it will show what it just displayed. In Netscape
you can get rid of this by going into Edit, Options, Advanced, Cache, and clear out the Disk Cache.
But this is really annoying after short order. The following prevents the above scenario:
function GetCurlPage ($pageSpec) {
$ch = curl_init($pageSpec);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tmp = curl_exec ($ch);
curl_close ($ch);
// if you intend to print this page, better clear out expiration tag
$tmp = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i',
'', $tmp);
return $tmp;
}
http://php.net/manual/en/function.curl-exec.php