首页 > php代码 > php curl、fopen、file_get_contents实例代码

php curl、fopen、file_get_contents实例代码

php教程 curl实例

<?php
session_write_close();
$pageurl = "http://www.phprm.com"; 
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); //打开本地文本


本文地址:http://www.phprm.com/code/33509.html

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

标签:none

发表留言