登录  /  注册
首页 >php教程 >php手册 > 正文

php curl、fopen、file_get_contents实例代码

原创2016-05-25 16:42:19833
//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('./people.txt', true); 
// > php 5 
$file = file_get_contents('./people.txt', file_use_include_path); //打开本地文本
登录后复制


本文地址:

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

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


视频教程分类

专题推荐

作者信息

php中文网

认证0级讲师