易截截图软件、单文件、免安装、纯绿色、仅160KB

用PHP抓取数据

用PHP实现简单的数据抓取
方法一:
<?php
     $urlstr = file_get_contents("http://www.baidu.com");
     $urlstr = htmlspecialchars($urlstr);
     print_r($urlstr);
?>
方法二:(需要打开curl扩展)
注意:打开curl扩展时,一定要看看php加载php.ini文件的路径,通过phpinfo()函数就可以看到php挂载的php.ini文件路径。
<?php
 //初始化curl 
 $ch = curl_init() or die (curl_error());
 curl_setopt($ch,CURLOPT_URL,"http://www.baidu.com/s?wd=php");  //要求CURL返回数据 
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  //执行请求 
 $result = curl_exec($ch) or die (curl_error());  //取得返回的结果,并显示 
 //echo $result;
 $result = htmlspecialchars($result);
 print_r($result);
 curl_close($ch);
?>
得到页面静态源代码后,就可以通过正则帅选你想要的结果,很方便。


相关文档:

oracle apache php乱码问题

办法一
select * from V$NLS_PARAMETERS
  $conn = oci_connect('scott', 'donkey', 'demo', 'zhs16gbk');
 while ($dat = oci_fetch_row($cur)) {  
    print_r(iconv('gb2312', 'utf-8', $dat[0]));  //$nickname = mb_convert_encoding($dat[0], 'utf-8', 'gbk');&n ......

PHP 中使用oracle 环境配置

http://www.oracle.com/technology/global/cn/pub/notes/technote_php_instant.html
为 Linux 和 Windows 安装 PHP 和 Oracle 10g Instant Client
作者:Christopher Jones,甲骨文公司的咨询技术人员
发布日期:2004 年 12 月
Oracle 10g Instant Client(免费下载)是PHP 与远程 Oracle 数据库连接的最简单方式,它 ......

如何在PHP中使用Oracle数据库

http://www.builder.com.cn/2007/1027/583048.shtml
在php3.0以上版本中,php内置了几乎目前所有的数据库处理函数,包括Oracle;在本文中我们通过一个实例来介绍了如何使用这些函数来操作Oracle数据库。
PHP提供了2大类API(应用程序接口)来操作Oracle数据库。一个是标准的Oracle处理函数(ORA) 另一个是Oracle 8调用接口函 ......

某大公司的PHP面试题(转载自PHP100)

1. 如何用php的环境变量得到一个网页地址的内容?ip地址又要怎样得到?
[php]
echo $_SERVER ['PHP_SELF'];
echo $_SERVER ['SERVER_ADDR'];
[/php]
2. 求两个日期的差数,例如2007-2-5 ~ 2007-3-6 的日期差数
[php]
$begin=strtotime('2007-2-5');
$end=strtotime('2007-3-6');
echo ($end-$begin)/(24*3600);
[ ......

php define() 函数及defined()函数的用法


The define() function defines a constant.
define()函数的作用是:定义一个常量。
Constants are much like variables, except for the following differences: 
常量[constant]与变量[variable]有很多相似的地方,因此,很容易混淆;下面,我们列举一下常量[constant]与变量[variable]之间的不同点:
A const ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号