>  기사  >  php教程  >  php curl、fopen、file_get_contents实例代码

php curl、fopen、file_get_contents实例代码

WBOY
WBOY원래의
2016-05-25 16:42:191149검색

//php curl实例代码如下: 
 
session_write_close(); 
$pageurl = "http://www.phprm.com/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实例,代码如下: 
 
$file = fopen("http://www.phprm.com/","r"); //读取远程文件 
$file = fopen("a.txt","r");//读取本地文件 
//php file_get_contents 
$homepage = file_get_contents('http://www.phprm.com/'); //读取远程文本 
echo $homepage; 
: 
// <= php 5 
$file = file_get_contents(&#39;./people.txt&#39;, true); 
// > php 5 
$file = file_get_contents(&#39;./people.txt&#39;, file_use_include_path); //打开本地文本


本文地址:

转载随意,但请附上文章地址:-)

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.