note 15698 deleted from function.fopen by jimw
| From: | jimw@php.net | Date: | Thu, 27 Sep 2001 18:52:17 +0000 |
| Subject: | note 15698 deleted from function.fopen by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-18379@lists.php.net to get a copy of this message | ||
/*
* File name: Your_File_name
* Description: PHP Scripts which gets the data from the
* Any website and we can perform regular expression funtions
* on that data afterwards to get our desired data.
* Author: Mohammad Asim Makki : densefunctions@hotmail.com
* Web Developer PHP/JAVA
* Nettech Limited --- Silcon Ways
*/
function getData($URL){
//Giving the String URL as argument it returns all webpage as a String to you
$allPage = "";
if($URL == null){ //Checking provided URL
echo("<b><font color=\"red\">Please specify a URL to get data from
</font></b>");
}
$fp= fopen($URL, r); //Opening Connection
if ( !$fp ) { // Check connection
echo("<b><font color=\"red\">Connection
Failed</font></b>");
}
else{
$num=0;
while ( !feof($fp) ){
$pageText[$num] = fread($fp,1024);// read WebPage
$num++;
}
//endwhile;
}
$arrayLen=count($pageText);
for($i=0; $i<$arrayLen; $i++){
$allPage=$allPage.$pageText[$i];
}
return $allPage;
}
//===Example of usage of function===
echo(getData("http://www.msn.com/"));