PHP 通过curl库函数获取网页内容
function get_web_page( $url )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page 返回网页
CURLOPT_HEADER => false, // 不返回头信息
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // 设置UserAgent
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect 连接超时
CURLOPT_TIMEOUT => 120, // timeout on response 回复超时
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
相关文档:
如何创建我们的第一个PHP页面呢?非常简单的!选择我们使用的一个最好的设计工具,当然你也可以 只使用记事本。创建之后记得要保存为扩展名为PHP的文件,然后传到我们的服务器
上。
在编写PHP程序之前通常我们需要配置我们的环境,也就是说服务器
要支持PHP才能行啊
一、PHP的基本结构:
使用Incl ......
软件下载地址:
pcre:http://www.pcre.org/
Nginx:http://nginx.net/
spawn-fcig: http://redmine.lighttpd.net/projects/spawn-fcgi/news
利用 wget 命令下载相应的 安装包
步骤
1、安装pcre
ngnix 需要安装pcre库:
wget http://sourceforge.net ......
// 我看过的两本书 PHP 的书中提及到 PHP6 的新特性,其中两个是 namespace 和 unicode,
// 从 PHP5.3 开始,php 已经支持 namespace 了; 而 Unicode 在 PHP5.3 中还没有发布。
//
// 看书看到 PHP 的多字节处理,想到前段时间还会自己截取 中英混合的字符串,那时候花了很长时间来看 utf-8,
// gbk, gb2312, gb180 ......
Ubuntu无疑是linux初学者的首选版本,因为它图形界面支持的非常好。
然而xammp是php初学者的首选。
1.什么是xammp?
XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建站集成软件包。这个软件包原来的名字是LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了。它可以在Windows、Linux、Solaris三种操作系统下安 ......
<?php
/**
* Mysql DB
*
* @author Administrator
* @package defaultPackage
*/
class MySqlDB{
private $_db;
private static $_instance;
private function __construct(&$db_type){
global $connectionstr;
$conn_db=$connectionstr[$db_type];
$this->_db=mysql_pconnect($conn ......