note 70288 added to function.fopen
| From: | http://www dot havarnielsen dot com at osu1 dot php dot net | Date: | Tue, 10 Oct 2006 13:01:04 +0000 |
| Subject: | note 70288 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118349@lists.php.net to get a copy of this message | ||
/* If you want to use parts of or an entire external page in your site, you can use this function to
fetch it using either curl or fopen. The output buffer functions used in the curl section enables
you to strip or format parts of the page before it is printed to the browserwindow. Curl is
recommended in most cases if php has been compiled to enable curl. It will take load off the server
and may prevent some hacking attempts.
// usage (for curl):
$data = open_external_url("http://www.php.net");
// (for fopen):
$data = open_external_url("http://www.php.net",
"fopen");
// use strpos, stristr, ereg_replace or any other string manipulation functions to strip
<body> or <html> or other elements.
echo $data;
*/
function open_external_url($url, $method = "curl")
{
$data = '';
if(strtolower($method) == "curl")
{
$ch = curl_init($url);
ob_start();
curl_exec($ch);
curl_close($ch);
$data = ob_get_contents();
ob_end_clean();
}
else if(strtolower($method) == "fopen")
{
$file = fopen($url, "r");
while(!feof($file)) {
$data = $data . fgets($file, 4096);
}
fclose ($file);
}
return $data;
}
----
Server IP: 83.137.200.2
Probable Submitter: 80.202.243.156
----
Manual Page -- http://www.php.net/manual/en/function.fopen.php
Edit -- https://master.php.net/note/edit/70288
Del: integrated -- https://master.php.net/note/delete/70288/integrated
Del: useless -- https://master.php.net/note/delete/70288/useless
Del: bad code -- https://master.php.net/note/delete/70288/bad+code
Del: spam -- https://master.php.net/note/delete/70288/spam
Del: non-english -- https://master.php.net/note/delete/70288/non-english
Del: in docs -- https://master.php.net/note/delete/70288/in+docs
Del: other reasons-- https://master.php.net/note/delete/70288
Reject -- https://master.php.net/note/reject/70288
Search -- https://master.php.net/manage/user-notes.php