PHP Tutorial Curl Instance
| The code is as follows |
Copy Code |
|
Session_write_close ();
$pageurl = "http://www.111cn.net/index.html";
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_url, $pageurl);
$html = curl_exec ($ch);
Curl_close ($ch);
Then you need to fix pathing to absolute
$search = "/(Src|href|background) =" [^:,^>,^ "]*"/I ";
Preg_match_all ($search, $html, $a _matches); |
PHP fopen Instance
| The code is as follows |
Copy Code |
|
$file = fopen ("http://www.111cn.net/", "R"); Reading remote Files
$file = fopen ("A.txt", "R");//Read local file |
PHP file_get_contents
$homepage = file_get_contents (' http://www.111cn.net/'); Reading remote text
Echo $homepage;
| The code is as follows |
Copy Code |
<= PHP 5
$file = file_get_contents ('./people.txt ', true);
> PHP 5
$file = file_get_contents ('./people.txt ', File_use_include_path); Open Local text |