首页 > PHP教程

php抓取百度快照、百度收录、百度热词程序代码


<?
/*
抓取百度收录代码
*/
function baidu($s){
  $baidu="http://www.baidu.com/s?wd=site%3A".$s;
  $site=file_get_contents($baidu);
  //$site=iconv("gb2312", "UTF-8", $site);
  ereg("找到相关网页(.*)篇,", $site,$count);
  $count=str_replace("找到相关网页","",$count);
  $count=str_replace("篇,","",$count);
  $count=str_replace("约","",$count);
  $count=str_replace(",","",$count);
  return $count[0];
}

阅读全文

php mysql搭建聊天室实例教程

MySQL并发能力强、响应速度快,是性能优异的数据库软件;PHP是功能强大的服务器端脚本语言。笔者在山西铝厂网站开发中,采用PHP4.0+MySQL3.23.38建立了多种应用。下面,以一个简单的聊天室设计为例,介绍PHP+MySQL在网页开发中的应用。

阅读全文

php oracle数据库实现分页

<html>
<body>
<?
include "/maya/inc/dbconn.php";
$sql="select max(rownum) from xqhtest where id<50";
$stmt=ociparse($gConn,$sql);
ociexecute($stmt);
ocifetch($stmt);
$rowcount=ociresult($stmt,1);
ocifreestatement($stmt);
echo("共有".$rowcount."条记录<br>n");
$recordperpage=15; //每页显示多少条记录
$pages=ceil($rowcount/$recordperpage);  //总页数
echo("共有".$pages."页<br>n");

阅读全文

php中循环实现(字符串,对象,或者数组)编码相互转换

/**
 * 循环实现编码互转
 *
 * @param string $param(字符串,对象,或者数组),$currCharset当前编码,$toCharset期望编码
 * @return 参数类型
 */
function zhandi_iconv($param,$currCharset,$toCharset){
 if ($currCharset != $toCharset){
  if (is_string($param)){
   return iconv($currCharset, $toCharset, $param);
  }
  elseif (is_array($param)){
   foreach ($param as $key => $value){
    $param[$key] = zhandi_iconv($value);
   }
   return $param;
  }
  elseif (is_object($param)){
   foreach ($param as $key => $value){
    $param->$key = zhandi_iconv($value);
   }
   return $param;
  }
  else{
   return $param;
  }
 }
 return $param;
}

阅读全文