php 问问采集代码

 更新时间:2016年11月25日 16:27  点击:1603
提供一款免费的php 问问采集代码哦,如果你正想采集问问,但是又不知道怎么写采集程序,这里为你提供一款经典的问问采集程序哦。
 代码如下 复制代码
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("stole_config.php");
require("conn.php");
require("keyword.php");
if(!empty($_post['ask']))
{
$ask=urlencode(trim($_post['ask']));//获取表单提交的问题
$sp="s".$ask;
}else
{
$sp=urlencode($_get['sp']);
}
if(empty($_get['jl']))
{
$_get['jl']=1;
}
$jl=$_get['jl'];
$pg=intval($_get['pg']);//获取页数
$rs=intval($_get['rs']);//获得 记录的参数
if($rs>9)
{
$rs=0;
$pg++;
}
if($pg>51)
{
echo "采集完毕! 总共采集 ".urldecode($sp)." ".$jl."条记录";
exit();
}
if($sp)//有设定答案才开始
{
$str=@file_get_contents("http://wenwen.soso.com/z/search.e?sp={$sp}&pg={$pg}");
@preg_match("/<ol class="result_list">(.*)</ol>/ius",$str,$asklist);//获取问答列表
//echo $asklist[1];
$url="/<a target="_blank" href="/z/(q.*.htm)/ius";
@preg_match_all($url,$asklist[1],$urllist);//获取 所有的问题
$t=$urllist[1][$rs];
$uid=$t;
$suid="ww{$uid}";
$sct=mysql教程_query("select count(*) from {$table_prefix}c_article where suid='$suid' ");
$sct=mysql_fetch_array($sct);
$sct=$sct[0];
if($sct==0)
{
$html=@file_get_contents("http://wenwen.soso.com/z/${t}");
$html=str_replace("<pre>","",str_replace("</pre>","",$html));
$html=str_replace("<br/><br/><br/>","<br/><br/>",$html);
//echo $html;
@preg_match("/<div class="question_main">.*<h3>(.*)</h3>/ius",$html,$ask_title);
$art_title=$ask_title[1];
@preg_match("/<div class="answer_con">(.*)</div>/ius",$html,$answer);
$j=count($answer)-1;
$art_content="";//商品详细
for($i=$j;$i>=1;$i--)
{
if(strlen($answer[$i])>$min_t1)
{
$art_content .= $answer[$i];
}
}
$art_content=trim($art_content);
$s1="/(<a .*>)(.*)</a>/ius";
$art_content=preg_replace($s1,${2},trim($art_content));
$word_arr=explode(",",iconv("gbk","utf-8",$cj_word));
$word_allow=false;//初始化是否允许采集
$word_count=count($word_arr);//总数
for($i=0;$i<$word_count;$i++)
{
if(substr_count($art_title,$word_arr[$i])>0)
{
$word_allow=1;
$i=$word_count;
}
}
if($word_allow)//如果合法
{ //开始处理数据库教程
if(strlen($art_content)>$min_t2)
{
echo "<font color=red>添加中............................</font><br>";
echo $art_title."<br>";
$art_title=iconv('utf-8','gbk', $art_title);
$title_ct=mysql_query("select count(*) from {$table_prefix}c_article where art_title ='$art_title' ");//查看标题是否重复
$title_ct=@mysql_fetch_array($title_ct);
$title_ct=$title_ct[0];
if($title_ct>0)
{
$art_title .="{$same_title}{$title_ct}";
}
$art_content=iconv('utf-8','gbk',str_replace(" ","<br>",$art_content));
$art_content=strtr($art_content,$keyword);
$art_time=date("y-m-d");
$sql="insert into {$table_prefix}c_article(art_title,art_content,art_time,art_author,suid) values('$art_title','$art_content','$art_time','$art_author','$suid')";//插入采集表
mysql_query($sql);
if(empty($t_catx_id))//如果无分类
{
$sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author}) values('$art_title','$art_content','$art_time','$art_author')";
}else
{
$sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author},{$t_catx_id}) values('$art_title','$art_content','$art_time','$art_author','$cat_id')";
}
mysql_query($sql2);//插入文章表
$jl++;//如果存放数据库中 则记录加1
//处理数据库结束
}else
{
echo "长度不够";
}
}else
{
echo "主题不符合要求";
}
}else
{
echo "已经存在";
}
$rs++;
//记录下本次采集 的状况
$f_tt= urldecode($sp)."--页数".$pg." 记录数 ".$jl ;
file_put_contents("ss.txt",$f_tt);
echo "<script>location.href='wenwen.php?jl=".$jl."&sp=".$sp."&pg=".$pg."&rs=".$rs." ';</script>";
exit();
}
?>
<link href="style.css教程" rel="stylesheet" type="text/css" />
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc">
<tr>
<td height="50" align="center" bgcolor="#00cc00"><h1><a href="http://www.111cn.net">荐礼啦</a>知道问问采集插件</h1></td>
</tr>
</table>
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc" style="margin-top:6px; margin-bottom:6px;">
<tr>
<td height="30" align="center" bgcolor="#ffffff"><a href="cj_config.php">采集设置</a> <a href="uninstall.php" onclick="return confirm('您确定要卸载采集插件吗');">卸载采集</a> <a href="cj_view.php">查看采集记录</a> <a href="cj_help.php">采集帮助</a> <a href="baidu.php" target="_blank">知道采集</a> <a href="wenwen.php" target="_blank">问问采集</a></td>
</tr>
</table>
<form action="wenwen.php" method="post">
<table width="628" height="49" border="0" align="center">
<tr>
<td width="413" align="right"><input name="ask" type="text" id="ask" size="50"></td>
<td width="205"><input type="submit" name="button" id="button" value="问问采集" style=" padding-left:15px; padding-right:15px; height:25px; line-height:25px;"></td>
</tr>
</table>
</form>
下面我收藏了三php删除文件哦,他可以利用unlink删除任何可删除的文件,本程序要删除文件,图片,压缩文件等,我们利用了几种方法来实例

三种php删除文件代码

 代码如下 复制代码

if($od=opendir($d))   //$d是目录名
{
        while(($file=readdir($od))!==false)  //www.111cn.net 读取目录内文件
        {
        unlink($file);  //$file是文件名
        }
}

去了解下这三个php函数:opendir()  readdir()  unlink()

文件删除代码二 系统调用法

 

 代码如下 复制代码
function del_dir($dir)
{
if(strtoupper(substr(php_os, 0, 3)) == 'win') {
       $str = "rmdir /s/q " . $dir;
} else {
       $str = "rm -rf " . $dir;
}
}

文件删除代码三

 代码如下 复制代码
$info = "a123"; //目录名
if(is_dir($info)){
if(rmdir($info)){
echo "目录{$inof}删除完毕www.111cn.net";
}else{
echo "目录无法删除!原因--可能是目录下还存在文件!";
}
}
if(is_file($info)){
if(unlink($info)){
echo "文件{$info}删除完毕...!";
}else{
echo "文件{$info}mb.111cn.net删除失败...!尝试修改文件权限删除...";
if(chmod($info,0777)){
unlink($info);
echo "文件{$info}权限修改后删除完毕...";
}else{
echo "文件{$info}无法通过web方式删除,可能是ftp权限对此文件有所设置...";
}
}
}

最近发现很多网站转载本站文件,注请加上本站连接,谢谢合作!

一款实例的php图片加水印,切头像图和自动缩放代码,他可以把你上传的图片生成指定大小的效果图与可以对图片进行自动切剪,下面看实例。
 代码如下 复制代码

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=gb2312">
  <meta name="author" content="verdana core, phpdoc.net inc.">
  <title>上传文件测试</title>
  </head>
<body>
  <form method=post  enctype="multipart/form-data" action="<?php echo url_for("upload/webimages",true);?>">
  <input type="file" name="upload" id="upload" onchange="preview()"; />
  <br /><br />
  <input type="submit" value="上传图片">
  </form>
  </body>
</html>

http://code.google.com/p/queryphp/downloads/list

frameworklibimg.class.php中的img类

<?
/*
php图片加水印,切头像图和自动缩放代码

*/

class uploadrouter extends controller{
  function index()
  {
    //输出上传表单,详见视图文件
  }
  function webimages()
  {
    print_r($_files);
    $img=c("img");
    $img->setinfo(  //设置上传文件属性
          array("files"=>"upload", //上传文件框名name
                "uploadpath"=>$globals['config']['webprojectpath']."upimages/", //上传目录
                "icopath"=>$globals['config']['webprojectpath']."upimages/",    //小图目录 如果不设置将是使用上传目录            
                "icowidth"=>"128",  //小图宽
                "icoheight"=>"98",  //小图高
                "fangpath"=>$globals['config']['webprojectpath']."upimages/_ico/", //切方图,就是切头像等
                "fangsize"=>"75", //方图多大 如果设置了切方图那么上传时候会生成切方图,不要可以不设置
                "nzsize"=>"180",   //自动设置宽或高不超这个
                "uploadsize"=>420000 //上传图片大小
                )
          )->setbasename($_files['upload']['name'],true)->init();//,'size_ico','auto_ico','fix_ico','fill_size''fix_side'
         //可以自己设置setbasename名不然会自动生成日期名字,其中会自动把中文换掉成拼音和过滤最后初始化init()
         //初始化完毕,可以上传了
    if($img->upload(array('fix_side'))) //上传了,设置要不要生成小图。有多种格式 如果是空那么只上传图片其它不理。
    {
      echo("上传成功");
    }else{
      echo("上传失败");
      echo $img->message;
    }
    return false;
  }
}


?>

本文章是一款图片上传代码,他可以把上传到服务器的图片在进行预览修改,如果是你想的你就可以保存了,不是可以删除再重新上传哦。

if(!isset($_session))session_start();

/**2010-6-22
 * $data 数组类型    包含以下变量
 -------------------------------
 * $sub_type        submit类型(upload:上传按钮    delete:删除按钮),默认upload
 * $file            通过表单获取的$_files['filename']数组
 * $img_tag_id        预览图片的<img>的id值
 * $img_dir            上传图片的目录
 * $max_file_size    单位m(兆),默认:1m
 * $type_array        允许的上传的图片类型(默认:image/pjpeg、image/jpeg、image/gif)
 **/
function upload($data){
    if(!$data['file']){
        echo '<script>alert("file不能为空!");</script>';exit;
    }
    if(!$data['img_tag_id']){
        echo '<script>alert("预览图片标签id不能为空!");</script>';exit;
    }
    if(!$data['img_dir']){
        echo '<script>alert("图片上传目录不能为空!");</script>';exit;
    }
    if(!isset($data['max_file_size'])){
        $data['max_file_size'] = 1024 * 1024;
    }else{
        $data['max_file_size'] = $data['max_file_size'] * 1024 * 1024;
    }
    if(!isset($data['type_array'])){
        $data['type_array'] = array('image/pjpeg', 'image/jpeg', 'image/gif');
    }
    if(!isset($data['sub_type'])){
        $data['sub_type'] = 'upload';
    }

    $imgpath = '';
    if(isset($data['sub_type']) && $data['sub_type'] == 'delete'){
        if(isset($_session['name']) && $_session['name']){
            if(is_file($_session['imgpath'])){
                $b = unlink($_session['imgpath']);
            }
            unset($_session['name'], $_session['imgpath']);
            if(!isset($_session['name'])){
                echo '<script>alert("删除成功!");</script>';
                echo '<script>parent.document.getelementbyid("'.$data['img_tag_id'].'").style.display = "none";</script>';
            }else{
                echo '<script>alert("删除失败!");</script>';
            }
        }else{
            echo '<script>alert("没有稿件!");</script>';
        }exit;
    }

    if(isset($_session['imgpath']) && $_session['imgpath']){
        echo '<script>alert("稿件已经存在,要想重新上传请删除原来的稿件!");</script>';exit;
    }
    if(!in_array($data['file']['type'], $data['type_array'])){
        echo '<script>alert("稿件类型不匹配,请上传.jpg、.gif和.png格式的图片!");</script>';exit;
    }
    if($data['file']['size'] > $data['max_file_size']){
        echo '<script>alert("您上传的稿件过大,请选择2m以下的图片上传!");</script>';exit;
    }

    if(!is_dir($data['img_dir'])){
        @mkdir($data['img_dir'], 0777, true);
    }
    $imgpath    = $data['img_dir'].'/'.date('his', time()).rand(100, 999).$data['file']['name'];
    $isupload    = move_uploaded_file($data['file']['tmp_name'], $imgpath);
    if(!$isupload){
        echo '<script>alert("稿件上传失败,请尝试重新上传!");</script>';exit;
    }else{
        echo '<script>alert("稿件上传成功!");</script>';
    }
    $_session['name']        = $data['file']['name'];
    $_session['imgpath']    = $imgpath;

    return $imgpath;
}

/*test_start*/
$sub_type = '';
if(isset($_post['submit_upload']))$sub_type = 'upload';
if(isset($_post['submit_delete']))$sub_type = 'delete';
if($sub_type){//echo '<script>alert("'.$sub_type.'");</script>';exit;
    $data = array(    'sub_type'        => $sub_type,
                    'file'            => $_files['file'],
                    'img_tag_id'    => 'picview',
                    'img_dir'        => 'upload_img',
                  );
    $imgpath = upload($data);
}else{
    $imgpath = isset($_session['imgpath'])? $_session['imgpath']: '';
}
?>

<form action="ad.php" method="post" enctype="multipart/form-data" target="frame">
    <input type="file" name="file" class="input">
    <input type="submit" name="submit_upload" value="上  传">
    <input type="submit" name="submit_delete" value="删  除">
    <iframe id="frame" name="frame" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
</form>

<img id="picview" height="100" style="display:none;">

<script>
if("<?php echo $imgpath; ?>"){
    parent.document.getelementbyid("picview").src = "<?php echo $imgpath; ?>";
    parent.document.getelementbyid("picview").style.display = "block";
}
</script>

现在流行的网站支持平台,支付宝当仁不让的老大了,现在我们就来告诉你如何使用支付宝api来做第三方支付,把支付宝放到自己网站来哈。
 代码如下 复制代码

*/
//alipay_config.php 配置程序
$interfaceurl = "https://www.alipay.com/payto:";
$sitename  = "网站名称";
$weburl   = "http://网站网址";
$o_fee   = "0.00";              //平邮费
$e_fee   = "0.00";              //快递费
$selleremail  = "";//支付宝账号
$payalikey  = "";//安全校验码
$imgurl   = "pay.gif"; //按钮图片源
$imgtitle  = "使用支付宝购买";           //按钮图片说明
?>
<?php
/*********************************************************************
 filename: alipay.php
 author:  dboyzhang
 version:  ver 2.0.0 beta1
 contact_me: wangwang:dboyzhang
*********************************************************************/

//alipay.php代码
require_once("alipay_config.php");
class alipay
{
 function geturl($s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11,$s12,$s13,$s14,$s15,$s16,$s17,$s18,$s19,$s20,$s21,$s22,$s23)
 {
  $parameter = array(
    'cmd'   => $s1,
    'subject'  => $s2,
    'body'   => $s3,
    'order_no'  => $s4,
    'price'   => $s5,
    'url'   => $s6,
    'type'   => $s7,
    'number'  => $s8,
    'transport'  => $s9,
    'ordinary_fee'  => $s10,
    'express_fee'  => $s11,
    'readonly'  => $s12,
    'buyer_msg'  => $s13,
    'seller'  => $s14,
    'buyer'   => $s15,
    'buyer_name'  => $s16,
    'buyer_address'  => $s17,
    'buyer_zipcode'  => $s18,
    'buyer_tel'  => $s19,
    'buyer_mobile'  => $s20,
    'partner'  => $s21,
  );

  $url = $s22.$s14."?";
  foreach($parameter as $key => $value){
    if($value){
      $url  .= $key."=".urlencode($value)."&";
      $acsouce .=$key.$value;
    }
  }
  $url  .= 'ac='.md5($acsouce.$s23);
  return $url;

 }
}
?>

pay.php页面

<?
error_reporting(0);
$aliname=$_post["aliname"];
$alizipcode=$_post["alizipcode"];
$aliphone=$_post["aliphone"];
$aliaddress=$_post["aliaddress"];
$aliorder=$_post["aliorder"];
$alimailtype=$_post["alimailtype"];
$alimoney=$_post["alimoney"];
$alimob=$_post["alimob"];
$alibody=$_post["alibody"];
?>
<?
require_once("alipay_config.php");
require_once("alipay.php");


$cmd   = '0001';
$subject  = "订单号:".$aliorder;
$body   = '商品介绍';
$order_no  = $aliorder;
$price   = $alimoney;
$url   = 'www.111cn.net';//你的网址
$type   = '1';
$number   =  '1';
$transport  = $alimailtype;
$ordinary_fee  = '0.00';
$express_fee  = '0.00';
$readonly  = 'true';
$buyer_msg  = $alibody;
$seller   = $selleremail;
$buyer   = '';
$buyer_name  = $aliname;
$buyer_address  = $aliaddress;
$buyer_zipcode  = $alizipcode;
$buyer_tel  = $aliphone;
$buyer_mobile  = $alimob;
$partner  = '2088002008096997';

$geturl = new alipay;
$link = $geturl->geturl
 (
 $cmd,$subject,$body,$order_no,$price,$url,$type,$number,$transport,
 $ordinary_fee,$express_fee,$readonly,$buyer_msg,$seller,$buyer,
 $buyer_name,$buyer_address,$buyer_zipcode,$buyer_tel,$buyer_mobile,$partner,
 $interfaceurl,$payalikey
 );
?>
<html>
<head>
<title>简易支付宝付款php版</title>
<link href="admin_style.css教程" rel=stylesheet>
<meta http-equiv=content-type content="text/html; charset=gb2312">
</head>

<body>
<table class=border id=table1 style="font-size: 9pt" height=185 cellspacing=0
cellpadding=0 width=492 align=center border=0>
  <tbody>
  <tr>
    <td class=topbg height=30>
      <div align=center><strong>简易支付宝付款php版</strong></div></td></tr>
  <tr>
    <td style="border-left: #e4e4e4 1px solid; border-bottom: #e4e4e4 1px solid" colspan=3 height=150>
      <table style="font-size: 9pt" height=137 width="100%" align=center bgcolor=#ffffff>
        <tbody>
        <tr class=tdbg>
          <td width="14%">订单号码:</td>
          <td width="86%"><? echo $aliorder; ?></td></tr>
        <tr class=tdbg>
          <td width="14%">收 货 人:</td>
          <td width="86%"><? echo $aliname; ?></td></tr>
        <tr class=tdbg>
          <td width="14%">付款金额:</td>
          <td width="86%"><b><? echo $alimoney; ?></b></td></tr>
        <tr class=tdbg>
          <td width="14%">收货地址:</td>
          <td width="86%"><? echo $aliaddress; ?></td></tr>
        <tr class=tdbg>
          <td>物流方式:</td>
          <td><? echo $alimailtype; ?> (1.平邮 2.快递 3.虚拟物品)</td></tr>
        <tr class=tdbg>
          <td>联系电话:</td>
          <td><? echo $aliphone; ?></td></tr>
        <tr class=tdbg>
          <td>邮政编码:</td>
          <td><? echo $alizipcode; ?></td></tr>
        <tr class=tdbg>
          <td>手机号码:</td>
          <td><? echo $alimob; ?></td></tr>
        <tr class=tdbg>
          <td>客户留言:</td>
          <td><? echo $alibody; ?></td></tr>
        <tr class=tdbg>
          <td></td>
          <td><input type="button" name="submit21" onclick="网页特效:history.go(-1)" value="返回修改订单">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo $link?>" target="_blank"><img src="<?php echo $imgurl?>" alt="<?php echo $imgtitle?>" border="0" align='absmiddle' border='0'/></a> </td></tr></tbody></table></td></tr></tbody></table>
 
</body></html>

 

[!--infotagslink--]

相关文章

  • 源码分析系列之json_encode()如何转化一个对象

    这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php中去除文字内容中所有html代码

    PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • index.php怎么打开?如何打开index.php?

    index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • 几种延迟加载JS代码的方法加快网页的访问速度

    本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
  • PHP中func_get_args(),func_get_arg(),func_num_args()的区别

    复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04
  • php导出csv格式数据并将数字转换成文本的思路以及代码分享

    php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07