php 自动分页类函数

 更新时间:2016年11月25日 16:26  点击:1493

php教程 自动分页类函数

不想重复的写sql代码,就用下面的函数去自动处理了。

$__t_page_moyo_html = '';
/**
*
* 临时代码:分页处理函数
* @param string $sql
*/
function page_moyo($sql = '')
{
    global $__t_page_moyo_html;
    if ($sql == '')
    {
        return $__t_page_moyo_html;
    }
    // config
    $max = 12;
    $flag = 'page';
    // step .1 处理sql语句
    $sql_count = preg_replace('/select.*?from/is', 'select count(*) as mcnt from', $sql);
    // step .2 获取数据量
    $result = dbc()->query($sql_count)->getrow();
    $total = $result['mcnt'];
    // step .3 判断是否需要分页
    if ($total < $max)
    {
        return $sql;
    }
    // step .4 获取当前页数
    $pn = isset($_get[$flag]) ? (int)$_get[$flag] : 1;
    if ($pn <= 0) $pn = 1;
    // step .5 重组sql语句
    $sql = $sql . ' limit '.($pn-1)*$max.','.$max;
    // step .6 组装分页html代码
    $url = $_server['request_uri'];
    if (preg_match('/'.$flag.'=d+/i', $url))
    {
        $url = preg_replace('/[&]?'.$flag.'=d+/', '', $url);
    }
    $pageall = ceil($total/$max);
    $pre = '';
    if ($pn > 1)
    {
        $pre = ' / <a href="'.$url.'&'.$flag.'='.($pn-1).'">上一页</a>';
    }
    $nxt = ' / <a href="'.$url.'&'.$flag.'='.($pn+1).'">下一页</a>';
    $html = '<a href="'.$url.'">首页</a>'.$pre.$nxt.' / <a href="'.$url.'&'.$flag.'='.$pageall.'">尾页</a>';
    $__t_page_moyo_html = $html;
    return $sql;
}


在进行sql查询前用page_moyo处理一下sql语句
     $sql = page_moyo($sql);
然后在需要显示分页链接的地方直接调用page_moyo输出
     echo page_moyo();

如果要连续进行两次大数据量sql查询的话就要在第一次查询后存储下当时的分页代码,不然下个sql查询就会覆盖掉了

 

ajax php教程仿网易文章评论顶一下效果

<div class='plding fr'>
<a href='action.php?id="1&action=top_num'>顶一下</a>[5]
</div>

js ajax

<script language="网页特效" type="text/javascript">
<!--
// ajax检测评论是否已经支持过了
function getcookie(c_name){ //检测cookie
 if (document.cookie.length>0){
  c_start=document.cookie.indexof(c_name + "=")
  if(c_start!=-1){
   c_start=c_start + c_name.length+1;
   c_end=document.cookie.indexof(";",c_start);
   if(c_end==-1) c_end=document.cookie.length;
   return unescape(document.cookie.substring(c_start,c_end));
  }
 }
 return "";
}

function setcookie(c_name,value,expiredays){ //设置cookie
 var exdate=new date();
 exdate.setdate(exdate.getdate()+expiredays);
 document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.togmtstring());
}

function createxmlhttprequest(){ //创建xmlhttprequest对象
 if(window.activexobject){  //ie
  try {
   return new activexobject("microsoft.xmlhttp");
  } catch(e){
   return;
  }
 }else if(window.xmlhttprequest){ //mozilla,firefox
  try {
   return new xmlhttprequest();
  } catch(e){
   return;
  }
 }
}

function get_top_num(id){ //主调函数
 var get_top_cookie=getcookie('get_top_'+id+'_cookie');
 if(get_top_cookie!=null && get_top_cookie!=""){
  alert('此条评论你已经支持过了');
 }
 else{
  var xmlhttp=createxmlhttprequest();
  var url = "action.php?action=top_num&id="+id;
  if (id==""){
   return false ;
  }
  if (xmlhttp){
   callback = getreadystatehandler(xmlhttp,id);
   xmlhttp.onreadystatechange = callback;
   xmlhttp.open("get", url,true);
   xmlhttp.send(null);
  }
  setcookie('get_top_'+id+'_cookie','istop',1);
 }
}

function getreadystatehandler(xmlhttp,id){  //服务器返回后处理函数
 var top_num = document.getelementbyid("top_num_"+id).innerhtml;
 return function (){
  if(xmlhttp.readystate == 4){
   if(xmlhttp.status == 200){
    if (xmlhttp.responsetext==1){
     document.getelementbyid("top_num_"+id).innerhtml=number(top_num)+1;
    }
   }
  }
 }
}

//-->
</script>

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>php教程 在线切图程序代码
</title>
<style>
/* { -moz-box-sizing:border-box; } */

body {
 background-color:#aaa;
 font-family:tahoma;
 font-size:12px;
}
a {
 text-decoration: none;
 outline:none;
}
a:focus {
 -moz-outline:none;
 outline:none;
}

#window {
 background-color:threedface;
 position:absolute;
 width:850px;   
 height:500px;
 left:10%;
 top:10%;

 border:1px solid;
 border-top-color:threedlightshadow;
 border-left-color:threedlightshadow;
 border-right-color:windowframe;
 border-bottom-color:windowframe;

 z-index:2;
}

#workspace {
 background-color:#ece9d8; /*threedface*/
 overflow:auto;

 position:absolute;
 width:98%;
 height:84%;
 top:51px;
 left:8px;
 right:0;
 bottom:74px;
 z-index:3;

 border:1px solid;
 border-top-color:threeddarkshadow;
 border-left-color:threeddarkshadow;
 border-right-color:threedhighlight;
 border-bottom-color:threedhighlight;
}

#myimg {
 display:none;
 position:absolute;
 margin:3px;
}
#canvas, #canvastemp { 
 display:none;
 position:absolute;
 margin:3px;
 background-color:transparent;
 border:1px solid #666666;
 /* background-image:url(back.gif);  */
}
#shapes{
 position:absolute;
 margin:3px;
}

#titlebar, #menubar, #statusbar, #resize {
 background-color:threedface;
 z-index:10;
 position:absolute;
}

#titlebar {
    left:2px;
 top:2px;
 height:22px;
 width:99.4%;
 overflow:hidden;

}
#gradient {
 width:100%;
 }
#menubar {
    left:0px;
 top:27px;
 height:20px;
 width:100%;
 list-style:none;
 margin:0;padding:0;
 z-index:10;
 border-bottom:1px solid threedshadow;
}

#menubar li {
 border:0px;
 margin:0;
 margin-top:1px;
 font:menu;
 float:left;
 padding:1px;
 padding-left:0.4em; padding-right:0.4em;
 cursor:default;
}

#statusbar {
 z-index:6;
 left:8px;
 bottom:0;
 height:26px;
 width:98%;
 border-top:1px solid threedhighlight;
 padding-top:2px;
}

#resize {
 z-index:100;
 bottom:0; right:0;
 width:15px; height:15px;
 background:transparent url('../resize.gif') 3px 3px no-repeat;
 cursor:nw-resize;
}

#titlebar canvas {
 position:absolute;
 width:100%;
}
#titlebar h1 {
 background:transparent url('../cut.gif') 1px 2px no-repeat;
 position:absolute;
 color:captiontext;
 font-size:12px;
 margin:0;padding:0;
 padding-left:20px;
 padding-top:2px;
 cursor:default;
}
#titlebar h2 {
 position:absolute;
 color:yellow;
 font-size:12px;
 margin:0;padding:0;
 right:8px;
 padding-top:2px;
 cursor:default;
}
#statusbar2 {
 margin-left:0px;
}

#statusbar2 > div {
 float:left;
}

#statusbar2 #status { float:left; width:57%;}
#statusbar2 #xy  { float:left; width:20%;}
#statusbar2 #txy  { float:left; width:20%;}

#status div, #xy div, #txy div {
 padding:3px;
 border:1px solid;
 border-top-color:threedshadow;
 border-left-color:threedshadow;
 border-right-color:threedhighlight;
 border-bottom-color:threedhighlight;
 height:1.3em;
 *height:1.7em;
 line-height:1.3em;
 overflow:hidden;
}
</style>
<script>
var mode = 1;
var inout = toubai = 0;
var img, imgurl = '', imgdata = '';
var p = '';
var xydir = 15;
var startangle=0, endangle=(math.pi/180)*270;
var m;
var win, wsp, canvas, c, canvastemp, ctemp, shapes;
var w,h,f;
var isshift = 0;
var shape = 0;
var theobject = null;
var dx, dy, dw, dh;
var des = '';
var iface = { dragging:false, resizing:false, status:null, xy:null, txy:null }
var anyt = 1;

var isie = /msie/i.test(navigator.useragent);
var isff = /firefox/i.test(navigator.useragent);

window.onload = function()
{  
 win = document.getelementbyid('window');
 wsp = document.getelementbyid('workspace');

 img = document.getelementbyid('myimg');
 canvas = document.getelementbyid('canvas');
 canvastemp = document.getelementbyid("canvastemp");
 shapes = document.getelementbyid('shapes');
 rects = document.getelementbyid('rect');
 
 win.style.left = document.body.clientwidth/2-425+'px';
 if (canvas.getcontext)
 {
  c = canvas.getcontext("2d");  
  c.linewidth = 1;
  c.strokestyle = '#f00'; 
  c.fillstyle = "rgba(255,255,255,0.3)";
  c.strokefill = 1;

  ctemp = canvastemp.getcontext("2d");
  ctemp.linewidth = 1;
  ctemp.strokestyle = '#f00';  
  ctemp.fillstyle = "rgba(255,255,255,0.3)";
  ctemp.strokefill = 1;
   
  var gradientcanvas = document.getelementbyid('gradient');
  if (gradientcanvas.getcontext)
  {
   var g = gradientcanvas.getcontext('2d');
   var grad = g.createlineargradient(0, 0, 1200, 22); 
   grad.addcolorstop(0, '#036');
   grad.addcolorstop(1, '#acf');
   g.fillstyle = grad;
   g.fillrect(0, 0, 1200, 22);
  }
  
  iface.status = document.getelementbyid('status').firstchild;
  iface.xy = document.getelementbyid('xy').firstchild;
  iface.txy = document.getelementbyid('txy').firstchild;
  
  document.onmouseup = window.onmouseup = bodyup;
  document.onmousemove = window.onmousemove = bodymove;
  document.onkeydown = window.onkeydown = keydown;
  document.onkeyup = window.onkeyup = keyup;
  img.onmousedown = canvas.onmousedown = canvastemp.onmousedown = shapes.onmousedown = c_down;
  img.onmousemove = canvas.onmousemove = canvastemp.onmousemove = shapes.onmousemove = c_move;
  img.onmouseup = canvas.onmouseup = canvastemp.onmouseup = shapes.onmouseup = c_up;
  img.onmouseo教程ut = canvas.onmouseout = canvastemp.onmouseout = c_out;
 }
 else //不支持canvas属性
 {
  alert('不支持canvas');  
 }

}

function openimg()
{
 var form = document.upimg;

 var file = form.ifile.value;
 var pos = file.lastindexof('.');
 var ext = file.substring(pos + 1).tolowercase();
 if (ext != 'jpg' && ext != 'gif' && ext != 'bmp' && ext != 'png')
 {
  alert('错误:上传图片必须是 jpg/gif/bmp/png 格式!');
  return;
 }
 form.submit.click();
 document.getelementbyid('upimg').style.display = 'none';
}

function upimg(url, size, ww, hh, ff)

 shape = 0;
 des = '大小:'+size+' 字节&nbsp;&nbsp;&nbsp;&nbsp;帧数:'+ff+' 帧&nbsp;&nbsp;&nbsp;&nbsp;宽度:'+ww+' 像素&nbsp;&nbsp;&nbsp;&nbsp;高度:'+hh+' 像素';
 iface.status.innerhtml=des;
 imgurl = url;
 imgdata = 'imgurl='+imgurl+';';
 if (ww>800) {w = 800; h = hh/(ww/800);}
 else {w = ww; h= hh;} 
 f = ff;
 //img.src = imgurl;
 document.getelementbyid('myimg').style.display = 'block';
 document.getelementbyid('myimg').src = imgurl;
 canvas.style.display='block';
 canvastemp.style.display='block';
 canvas.width = canvastemp.width = w;
 canvas.height = canvastemp.height = h;
 canvas.style.width = canvastemp.style.width = w+'px';
 canvas.style.height = canvastemp.style.height = h+'px';
 c.clearrect(0, 0, canvas.width, canvas.height);
 ctemp.clearrect(0, 0, canvastemp.width, canvastemp.height);
 c.strokestyle = '#f00'; 
 c.fillstyle = "rgba(255,255,255,0.3)";
 ctemp.strokestyle = '#f00';  
 ctemp.fillstyle = "rgba(255,255,255,0.3)";
}

function init(t)
{
 if (imgurl == '') {alert('请先上传图片!');return;}
 else alert("当前版本是演示版!");
}
function reset()
{
 if (imgurl == '') {alert('请先上传图片!');return;}
 else alert("当前版本是演示版!");
}
function clip()
{
 if (imgurl == '') {alert('请先上传图片!');return;}
 else alert("当前版本是演示版!");
}

function hover(o)
{
 o.style.border = "1px solid";
 o.style.bordercolor = "threedhighlight threeddarkshadow threeddarkshadow threedhighlight";
}
function hoverout(o)
{
 o.style.border = "0px solid transparent";
}

function help()
{
 document.getelementbyid('help').style.display='block';
}
function about()
{
 document.getelementbyid('about').style.display='block';
}
function wrong(str)
{
 alert(str);
}
</script>
<!--[if ie]>
 <script type="text/网页特效" src="js/excanvas.js"></script>
 <![endif]-->
</head>

<body id="body">
<form name="build" enctype="multipart/form-data"><input type="hidden" name="imgdata"><input type="hidden" name="region"><input type="hidden" name="back"><input type=submit name=submit style="position:absolute;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;");></form>

<div id="window">

 <div id="titlebar" onmousedown="windowdrag(event)" oncontextmenu="return false"><canvas id="gradient" height="22"></canvas><h1 style="margin-top:2px;">图片裁剪工具</h1><h2 style="margin-top:1px;"><a href="javascript:help();" hidefocus="true"><font color=yellow>操作说明</font></a>&nbsp;&nbsp;<a href="javascript:about();" hidefocus="true"><font color=yellow>关于我们</font></a></h2>
 </div>
 <ul id="menubar" oncontextmenu="return false">
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="document.getelementbyid('help').style.display='none';document.getelementbyid('about').style.display='none';document.getelementbyid('set').style.display='none';document.getelementbyid('upimg').style.display='block';">&nbsp;上传图片(<u>u</u>)</li>
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(1);">矩形裁剪(<u>r</u>)</li> 
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(2)">圆形裁剪(<u>o</u>)</li>
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(3)">圆角矩形裁剪(<u>c</u>)</li>
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(4)">圆弧裁剪(<u>a</u>)</li>
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(5)">多边形裁剪</li>
  <li style="top:0px;margin-left:-3px;padding-left:0px;margin-top:-2px;padding-top:0px;padding-bottom:0px;"><input type="radio" name="any" id="line" hidefocus disabled checked>直边<input type="radio" name="any" id="curve" hidefocus disabled>曲边</li>
  <li onmouseover="hover(this)" onmouseout="hoverout(this)" onclick="init(6)">任意图形裁剪(<u>m</u>)</li>
  <li style="margin-top:0px;margin-right:7px;*margin-right:5px;float:right;padding-top:1px;*padding-top:2px;padding-bottom:1px;*padding-bottom:0px;border:1px solid threeddarkshadow;color:red" onclick="clip()">裁剪</li>
  <li style="margin-top:0px;margin-right:7px;*margin-right:5px;float:right;padding-top:1px;*padding-top:2px;padding-bottom:1px;*padding-bottom:0px;border:1px solid threeddarkshadow;color:red" onclick="reset()">重置</li>
  <li style="margin-top:0px;margin-right:7px;*margin-right:5px;float:right;padding-top:1px;*padding-top:2px;padding-bottom:1px;*padding-bottom:0px;border:1px solid threeddarkshadow;color:red" onclick="document.getelementbyid('set').style.display='block'">设置</li>
 </ul>
   
 <div id="workspace" oncontextmenu="return false">
  <img id="myimg">
  <canvas id="canvas" oncontextmenu="return false"></canvas>
  <canvas id="canvastemp" oncontextmenu="return false"></canvas>
  <div id="shapes">
   <table class=resizeme id=rect style="position:absolute;z-index:100;border:0px dotted #ff0000;width:100;height:100;display:none;" cellspacing="0" cellpadding="0"><tr><td></td></tr></table>
  </div>
 </div>

 <div id="statusbar" oncontextmenu="return false"><div id="statusbar2">
  <div id="status"><div>&nbsp;</div></div>
  <div id="xy"><div>&nbsp;</div></div>
  <div id="txy"><div>&nbsp;</div></div>
 </div></div>
 <div id="resize" onmousedown="windowresize(event, this)" oncontextmenu="return false"></div>

 <form id="upimg" name="upimg" action="upload.php" method="post" enctype="multipart/form-data" target="_frame" style="position:absolute;background-color:#036;left:50%;top:50%;margin-left:-163px;*margin-left:-175px;margin-top:-80px;width:325px;*width:350px;padding-top:3px;padding-left:3px;padding-bottom:3px;padding-right:3px;z-index:12;display:none">
  <div style="background-color:#036;padding-top:1px;padding-left:2px;color:captiontext;font-size:12px;height:20px"><b>&nbsp;上传图片</b></div>
  <div style="background-color:threedface;padding-top:6px;padding-bottom:6px;padding-left:10px;"><input size="24" type="file" name="ifile" onchange="openimg();" style="height:22px">&nbsp;<input type="button" value=" 取 消 " style="height:22px" onclick="document.getelementbyid('upimg').style.display='none'"><input type=submit name=submit style="position:absolute;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;"></div>
 </form>
 
 <form id="set" name="set" style="position:absolute;background-color:#036;left:50%;top:50%;margin-left:-125px;margin-top:-80px;width:250px;padding-top:3px;padding-left:3px;padding-bottom:3px;padding-right:3px;z-index:12;display:none">
  <div style="background-color:#036;padding-top:1px;padding-left:2px;color:captiontext;font-size:12px;height:20px"><b>&nbsp;设置</b></div>
  <div><div style="background-color:threedface;padding-top:6px;padding-bottom:6px;padding-left:24px">裁剪方向:<input type="radio" name=inout id=isin hidefocus checked>裁剪内部&nbsp;<input type="radio" name=inout id=isout hidefocus>裁剪外部<p style="margin-top:3px;margin-bottom:3px">背景颜色:<input type="radio" name=toubai id=istou value=0 hidefocus checked>透明背景&nbsp;<input type="radio" name=toubai id=isbai value=1 hidefocus>白色背景</div><div style="background-color:threedface;padding-bottom:8px;"><center><input type="button" value=" 确 定 " style="height:22px" onclick="setting()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value=" 取 消 " style="height:22px" onclick="document.getelementbyid('set').style.display='none'"></center></div></div>
 </form>
 
 <div id="help" style="position:absolute;background-color:#036;left:50%;top:50%;margin-left:-210px;margin-top:-170px;width:420px;padding-top:3px;padding-left:3px;padding-bottom:3px;padding-right:3px;z-index:12;display:block">
  <div style="background-color:#036;padding-top:1px;padding-left:2px;color:captiontext;font-size:12px;height:20px"><b>&nbsp;操作说明</b></div>
  <div><div style="background-color:threedface;padding-top:6px;padding-bottom:6px;padding-left:10px;padding-right:10px"><center><font color=red>【鼠标操作说明】</font></center><p style="margin-top:6px;margin-bottom:6px">[1] 鼠标拖动裁剪框可移动裁剪区域的位置,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。<p style="margin-top:4px;margin-bottom:4px">[2] 鼠标拉拽裁剪框边框可调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。<p style="margin-top:8px;margin-bottom:8px"><center><font color=red>【键盘操作说明】</font></center><p style="margin-top:6px;margin-bottom:6px">[3] 按←↑↓→键可精确移动裁剪区域的位置,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。<p style="margin-top:4px;margin-bottom:4px">[4] 按jklm键可精确调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。<p style="margin-top:4px;margin-bottom:4px">[5] 按a键减小圆角矩形的圆角角度,按d键增大圆角矩形的圆角角度,此操作适用于圆角矩形裁剪。<p style="margin-top:4px;margin-bottom:4px">[6] 按awsd键可调整圆弧的弧度,此操作适用于圆弧裁剪。<p style="margin-top:8px;margin-bottom:8px"><center><font color=red>【shift操作说明】</font></center><p style="margin-top:6px;margin-bottom:6px">[7] 拉拽鼠标的同时按shift键可按宽与高1:1的比例调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪。</div><div style="background-color:threedface;padding-bottom:8px;"><center><input type="button" value=" 关 闭 " style="height:22px" onclick="document.getelementbyid('help').style.display='none'"></center></div></div>
 </div>
 
 <div id="about" style="position:absolute;background-color:#036;left:50%;top:50%;margin-left:-190px;margin-top:-120px;width:380px;padding-top:3px;padding-left:3px;padding-bottom:3px;padding-right:3px;z-index:12;display:none">
  <div style="background-color:#036;padding-top:1px;padding-left:2px;color:captiontext;font-size:12px;height:20px"><b>&nbsp;关于我们</b></div>
  <div><div style="background-color:threedface;padding-top:8px;padding-bottom:6px;padding-left:10px"><center><font color=red>【本站宗旨】</font></center><p style="margin-top:6px;margin-bottom:6px">● 本站旨在为广大网民提供最专业最全面的图片裁剪服务.<p style="margin-top:8px;margin-bottom:8px"><center><font color=red>【站点说明】</font></center><p style="margin-top:6px;margin-bottom:6px">● 本站提供以下服务:图片裁剪,照片裁剪,矩形裁剪,圆形裁剪,弧形裁剪,多边形裁剪,任意图形裁剪,动态图片裁剪.<p style="margin-top:8px;margin-bottom:8px"><center><font color=red>【联系我们】</font></center><p style="margin-top:6px;margin-bottom:6px">● 对本站如有疑问之处请与我们联系:service@caijian.cc.</div><div style="background-color:threedface;padding-bottom:8px;"><center><input type="button" value=" 关 闭 " style="height:22px" onclick="document.getelementbyid('about').style.display='none'"></center></div></div>
 </div>
 
 <div style="display:none;">
  <iframe id="_frame" name="_frame"></iframe>
 </div> 
 
</div>
</body>
</html>

upload.php文件
<?php
 if (stripos($_server[ "http_host"], 'caijian.cc') === false) exit(0);
 if ((($_files["ifile"]["type"] == "image/gif")
  || ($_files["ifile"]["type"] == "image/jpeg")
  || ($_files["ifile"]["type"] == "image/pjpeg")
  || ($_files["ifile"]["type"] == "image/bmp")
  || ($_files["ifile"]["type"] == "image/png"))
  && ($_files["ifile"]["size"] < 3000000))
 {
  if ($_files["ifile"]["error"] > 0)
  {
   echo  "<script language='javascript'>" ;
   echo  "parent.wrong('上传图片出错,请重新上传!');";
   echo  "</script>";
  }
  else
  {
   $filename = "upload/".date("ymdhis",time()).rand(100,999).substr($_files["ifile"]["name"],strrpos($_files["ifile"]["name"],'.'));
   move_uploaded_file($_files["ifile"]["tmp_name"], $filename);
   
   $magick_wand = newmagickwand();
   magickreadimage($magick_wand, $filename);
   $w = magickgetimagewidth($magick_wand);
   $h = magickgetimageheight($magick_wand);
   $f = magickgetnumberimages($magick_wand);
   
   echo  "<script language='javascript'>" ;
   echo  "parent.upimg('".$filename."',".$_files["ifile"]["size"].", $w, $h, $f);";
   echo  "</script>";
  }
 }
 else
 {
  echo  "<script language='javascript'>" ;
  echo  "parent.wrong('上传照片尺寸不得大于3m!');";
  echo  "</script>";
 }
?>

源码下载地址
http://down.111cn.net/php/2011/0311/22879.html

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php教程 文件图片上传类程序</title>
</head>

<body>

<form enctype="multipart/form-data" action="upx.php" method="post">
 <input name="swfile" type="file">
 <input type="submit" value="上传">
</form>
</body>
</html>
upx.php文件
<?php
//上传操作
require_once './libs/uploadx.php';
$upx = new uploadx();
$upx->uploadx_form = 'swfile';
$upx->uploadx_save = "upload";
$upx->uploadx_size = "1024";
$upx->uploadx_name = time();
$upx->file();
print_r($upx->file);

?>
uploadx.php类文件
<?php
/*

使用方法:

html表单页
-------------------------------------------------------------------------
<form enctype="multipart/form-data" action="upload.php" method="post">
 <input name="swfile" type="file">
 <input type="submit" value="上传">
</form>
-------------------------------------------------------------------------


upload.php处理页
-------------------------------------------------------------------------
<?php
require_once './uploadx.php';
$upx = new uploadx();
$upx->uploadx_form = 'swfile';              //表单控件名称(表单上传控件的名称<input name="swfile" type="file" />)
$upx->uploadx_save = "temp";                //保存文件目录(上传文件保存目录可以是相对路径也可以是绝对路径)
$upx->uploadx_type = 'jpg|gif|png|swf';    //允许上传类型(根据后缀限制上传类型,每个后缀用"|"隔开) 
$upx->uploadx_size = "1024";                //允许上传大小(单位是kb。例:1024=1024kb)
$upx->uploadx_name = time();                //上传后文件名(可自定义。例:date("y-m-d",time()))

if($upx->file()){
  echo "上传成功<br />";
  echo "名称->".$upx->file['name']."<br />";
  echo "路径->".$upx->file['path']."<br />";
  echo "大小->".$upx->file['size']."<br />";
  echo "类型->".$upx->file['type']."<br />";
  echo "时间->".$upx->file['time']."<br />";
  echo "结果->".$upx->file['info']."<br />";
 
}else{
  echo $upx->file['info'];
}

 

-------------------------------------------------------------------------
*/
class uploadx {

       
       public $uploadx_form; //表单控件名称
       public $uploadx_save; //保存文件目录
       public $uploadx_type; //允许上传类型
       public $uploadx_size; //允许上传大小
       public $uploadx_name; //上传后文件名
      
       function __construct(){//初始化函数
          $this->uploadx_form = 'attach';
          $this->uploadx_save = 'temp';
          $this->uploadx_type = 'jpg|gif|png|swf|flv|rar|7z|zip|doc|docx|ppt|pptx|xls|xlsx|txt|pdf|wav|mp3|wma|rm|rmvb|wmv';        
          $this->uploadx_size = '1024';
          $this->uploadx_info = false;
       }
      
      function mkdirs($path , $mode = 0777){
          $rootdir = '';
          if(substr($path,0,1)=='/') $rootdir = $_server['document_root'];         
          $path = $rootdir . $path;
          if(!is_dir($path)){
              $this->mkdirs(dirname($path),$mode);
              mkdir($path,$mode);
          }
          return true;
      }

 

     function file(){
              if(!isset($_files[$this->uploadx_form])){
                  $this->file = array('file'=>false,'info' => '上传错误!请检查表单上传控件名称['.$this->uploadx_form.']是否正确!');
                  return false;
              }
             
              switch($_files[$this->uploadx_form]['error']){
                
                 case 1:
                  $this->file = array('file'=>false,'info' => '指定上传的文件大小超出服务器限制!');
                  return false;
                 break; 
                
                 case 2:
                  $this->file = array('file'=>false,'info' => '指定上传的文件大小超出表单限制!');
                  return false;
                 break; 
                                            
                 case 3:
                  $this->file = array('file'=>false,'info' => '只有部份文件被上传,文件不完整!');
                  return false;
                 break; 
                                                     
                 case 4:
                  $this->file = array('file'=>false,'info' => '您没有选择上传任何文件!');
                  return false;
              }
             
              $postfix = pathinfo($_files[$this->uploadx_form]['name'], pathinfo_extension); 
              if(stripos($this->uploadx_type,$postfix)===false){
                $this->file = array('file'=>false,'info' => '指定上传的文件类型超出限制,允许上传文件类型:'.$this->uploadx_type);
                return false;
               
              }
         
              if(round($_files[$this->uploadx_form]['size']/1024)>$this->uploadx_size){
                $this->file = array('file'=>false,'info' => '指定上传的文件超出大小限制,文件上传限制范围:'.$this->uploadx_size.'kb');
                return false; 
              }               
           
              if($this->mkdirs($this->uploadx_save)){             
                $this->uploadx_name = isset($this->uploadx_name) ? $this->uploadx_name.'.'.$postfix : $_files[$this->uploadx_form]['name'];
                if(!@move_uploaded_file($_files[$this->uploadx_form]['tmp_name'],$this->uploadx_save.'/'.$this->uploadx_name)){
                  $this->file = array('file'=>false,'info' => '上传文件保存过程中出现错误,请检查路径或目录权限.');
                  return false;
                }
              }else{
                 $this->file = array('file'=>false,'info' => '服务器目录不存在,自动创建目录失败,请检查是否有权限!');
                  return false;
              }                
             
              @chmod($this->uploadx_save.'/'.$this->uploadx_name,0777);    
              $this->file = array(
                    'file' => true,
                    'name' => $this->uploadx_name,
                    'path' => $this->uploadx_save.'/'.$this->uploadx_name,
                    'size' => $_files[$this->uploadx_form]['size'],
                    'type' => $postfix,
                    'time' => time(),
                    'info' => '上传成功!'
              );               
              return true;
                        
     }


}

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh_cn" lang="zh_cn">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php教程 多文件上传组件</title>
</head>
<body bgcolor="#ffffff" style="text-align:center;">
  <!--影片中使用的 url-->
  <!--影片中使用的文本-->
  <!-- saved from url=(0013)about:internet -->
  <script language="网页特效">
function challs_flash_update(){ //flash 初始化函数
 var a={};
 //定义变量为object 类型

 a.title = "上传文件"; //设置组件头部名称
 
 a.formname = "filedata";
 //设置form表单的文本域的name属性
 
 a.url="update.php";
 //设置服务器接收代码文件
 
 a.parameter="bs=tyi&id=50";
 //设置提交参数,以get形式提交
 
 a.typefile=["images (*.gif,*.png,*.jpg,*jpeg)","*.gif;*.png;*.jpg;*.jpeg;","gif (*.gif)","*.gif;","png (*.png)","*.png;","jpeg (*.jpg,*.jpeg)","*.jpg;*.jpeg;"];
 //设置可以上传文件 数组类型
 //"images (*.gif,*.png,*.jpg)"为用户选择要上载的文件时可以看到的描述字符串,
 //"*.gif;*.png;*.jpg"为文件扩展名列表,其中列出用户选择要上载的文件时可以看到的 windows 文件格式,以分号相隔
 //2个为一组,可以设置多组文件类型
 
 a.ups教程ize=0;
 //可限制传输文件总容量,0或负数为不限制,单位mb
 
 a.filenum=0;
 //可限制待传文件的数量,0或负数为不限制
 
 a.size=1;
 //上传单个文件限制大小,单位mb,可以填写小数类型
 
 a.formid=['select','select2'];
 //设置每次上传时将注册了id的表单数据以post形式发送到服务器
 //需要设置的form表单中checkbox,text,textarea,radio,select项目的id值,radio组只需要一个设置id即可
 //参数为数组类型,注意使用此参数必须有 challs_flash_formdata() 函数支持
 
 a.autoclose=1;
 //上传完成条目,将自动删除已完成的条目,值为延迟时间,以秒为单位,当值为 -1 时不会自动关闭,注意:当参数completeclose为false时无效
 
 a.completeclose=true;
 //设置为true时,上传完成的条目,将也可以取消删除条目,这样参数 upsize 将失效, 默认为false
 
 a.repeatfile=true;
 //设置为true时,可以过滤用户已经选择的重复文件,否则可以让用户多次选择上传同一个文件,默认为false
 
 a.returnserver=true;
 //设置为true时,组件必须等到服务器有反馈值了才会进行下一个步骤,否则不会等待服务器返回值,直接进行下一步骤,默认为false
 
 a.md5file = 1;
 //设置md5文件签名模式,参数如下 ,注意:flash无法计算超过100m的文件,在无特殊需要时,请设置为0
 //0为关闭md5计算签名
 //1为直接计算md5签名后上传
 //2为计算签名,将签名提交服务器验证,在根据服务器反馈来执行上传或不上传
 //3为先提交文件基本信息,根据服务器反馈,执行md5签名计算或直接上传,如果是要进行md5计算,计算后,提交计算结果,在根据服务器反馈,来执行是否上传或不上传
 
 a.loadfileorder=true;
 //选择的文件加载文件列表顺序,true = 正序加载,false = 倒序加载
 
 a.mixfilenum=0;
 //至少选择的文件数量,设置这个将限制文件列表最少正常数量(包括等待上传和已经上传)为设置的数量,才能点击上传,0为不限制
 
 a.listshowtype = 1;
 //文件列表显示类型:1 = 传统列表显示,2 = 缩略图列表显示(适用于图片专用上传)
 
 a.infodownright = "等待上传:%1%个  已上传:%2%个";
 //右下角统计信息的文本设置,文本中的 %1% = 等待上传数量的替换符号,%2% = 已经上传数量的替换符号
 
 return a ;
 //返回object
}

function challs_flash_oncomplete(a){ //每次上传完成调用的函数,并传入一个object类型变量,包括刚上传文件的大小,名称,上传所用时间,文件类型
 var name=a.filename; //获取上传文件名
 var size=a.filesize; //获取上传文件大小,单位字节
 var time=a.updatetime; //获取上传所用时间 单位毫秒
 var type=a.filetype; //获取文件类型,在 windows 上,此属性是文件扩展名。 在 macintosh 上,此属性是由四个字符组成的文件类型
 document.getelementbyid('show').innerhtml+=name+' --- '+size+'字节 ----文件类型:'+type+'--- 用时 '+(time/1000)+'秒<br><br>'
}

function challs_flash_oncompletedata(a){ //获取服务器反馈信息事件
 document.getelementbyid('show').innerhtml+='<font color="#ff0000">服务器端反馈信息:</font><br />'+a+'<br />'; 
}
function challs_flash_onstart(a){ //开始一个新的文件上传时事件,并传入一个object类型变量,包括刚上传文件的大小,名称,类型
 var name=a.filename; //获取上传文件名
 var size=a.filesize; //获取上传文件大小,单位字节
 var type=a.filetype; //获取文件类型,在 windows 上,此属性是文件扩展名。 在 macintosh 上,此属性是由四个字符组成的文件类型
 document.getelementbyid('show').innerhtml+=name+'开始上传!<br />';
 
 return true; //返回 false 时,组件将会停止上传
}

function challs_flash_oncompleteall(a){ //上传文件列表全部上传完毕事件,参数 a 数值类型,返回上传失败的数量
 document.getelementbyid('show').innerhtml+='<font color="#ff0000">所有文件上传完毕,</font>上传失败'+a+'个!<br />';
 //window.location.href='http://www.access2008.cn/update'; //传输完成后,跳转页面
}

function challs_flash_onerror(a){ //上传文件发生错误事件,并传入一个object类型变量,包括错误文件的大小,名称,类型
 var err=a.texterr; //错误信息
 var name=a.filename; //获取上传文件名
 var size=a.filesize; //获取上传文件大小,单位字节
 var type=a.filetype; //获取文件类型,在 windows 上,此属性是文件扩展名。 在 macintosh 上,此属性是由四个字符组成的文件类型
 document.getelementbyid('show').innerhtml+='<font color="#ff0000">'+name+' - '+err+'</font><br />';
}

function challs_flash_formdata(a){ // 使用formid参数时必要函数
 try{
  var value = '';
  var id=document.getelementbyid(a);
  if(id.type == 'radio'){
   var name = document.getelementsbyname(id.name);
   for(var i = 0;i<name.length;i++){
    if(name[i].checked){
     value = name[i].value;
    }
   }
  }else if(id.type == 'checkbox'){
   if(id.checked){
    value = id.value;
   }
  }else{
   value = id.value;
  }
  return value;
  }catch(e){
  return '';
  }
}

function challs_flash_style(){ //组件颜色样式设置函数
 var a = {};
 
 /*  整体背景颜色样式 */
 a.backgroundcolor=['#f6f6f6','#f3f8fd','#dbe5f1']; //颜色设置,3个颜色之间过度
 a.backgroundlinecolor='#5576b8';     //组件外边框线颜色
 a.backgroundfontcolor='#066ad1';     //组件最下面的文字颜色
 a.backgroundinsidecolor='#ffffff';     //组件内框背景颜色
 a.backgroundinsidelinecolor=['#e5edf5','#34629e']; //组件内框线颜色,2个颜色之间过度
 a.upbackgroundcolor='#ffffff';      //上翻按钮背景颜色设置
 a.upoutcolor='#000000';        //上翻按钮箭头鼠标离开时颜色设置
 a.upovercolor='#ff0000';       //上翻按钮箭头鼠标移动上去颜色设置
 a.downbackgroundcolor='#ffffff';     //下翻按钮背景颜色设置
 a.downoutcolor='#000000';       //下翻按钮箭头鼠标离开时颜色设置
 a.downovercolor='#ff0000';       //下翻按钮箭头鼠标移动上去时颜色设置
 
 /*  头部颜色样式 */
 a.top_backgroundcolor=['#e0eaf4','#bcd1ea'];   //颜色设置,数组类型,2个颜色之间过度
 a.top_fontcolor='#245891';       //头部文字颜色
 
 
 /*  按钮颜色样式 */
 a.button_overcolor=['#fbdab5','#f3840d'];   //鼠标移上去时的背景颜色,2个颜色之间过度
 a.button_overlinecolor='#e77702';     //鼠标移上去时的边框颜色
 a.button_overfontcolor='#ffffff';     //鼠标移上去时的文字颜色
 a.button_outcolor=['#ffffff','#dde8fe'];    //鼠标离开时的背景颜色,2个颜色之间过度
 a.button_outlinecolor='#91bdef';     //鼠标离开时的边框颜色
 a.button_outfontcolor='#245891';     //鼠标离开时的文字颜色
 
 /* 文件列表样式 */
 a.list_backgroundcolor='#eaf0f8';     //列表背景色
 a.list_fontcolor='#333333';       //列表文字颜色
 a.list_linecolor='#b3cdf1';       //列表分割线颜色
 a.list_canceloverfontcolor='#ff0000';    //列表取消文字移上去时颜色
 a.list_canceloutfontcolor='#d76500';    //列表取消文字离开时颜色
 a.list_progressbarlinecolor='#b3cdf1';    //进度条边框线颜色
 a.list_progressbarbackgroundcolor='#d8e6f7';  //进度条背景颜色 
 a.list_progressbarcolor=['#ffcc00','#ffff00'];  //进度条进度颜色,2个颜色之间过度
 
 /* 错误提示框样式 */
 a.err_backgroundcolor='#c0d3eb';     //提示框背景色
 a.err_linecolor='#5d7cbb';       //提示框边框线景色
 a.err_cancelovercolor='#0066cc';     //提示框取消按钮移上去时颜色
 a.err_canceloutcolor='#ff0000';      //提示框取消按钮离开时颜色
 a.err_fontcolor='#245891';       //提示框文字颜色
 
 
 return a;
}


var ismsie = (navigator.appname == "microsoft internet explorer");  
function thismovie(moviename){  
  if(ismsie){  
   return window[moviename];  
  }else{
   return document[moviename];  
  }  
}
</script>
  <p><a href="temp2.html">缩略图模式</a></p>
这个选择框的数据将以post形式和图片一起传送到服务器
  <select id="select">
    <option value="老虎">老虎</option>
    <option value="兔子">兔子</option>
    <option value="骏马">骏马</option>
    </select>
    <select id="select2">
      <option value="石头">石头</option>
      <option value="剪子">剪子</option>
      <option value="布">布</option>
      </select>
    <br>
    <br>
  改变窗口:高
<label>
      :
      <input name="gao" type="text" id="gao" value="320" size="5">
      宽:
      </label>
      <label>
      <input name="kuan" type="text" id="kuan" value="408" size="5"> 
      </label>
      <label>
      <input type="submit" name="button" id="button" value=" 修 改 " onclick="thismovie('update').width=document.getelementbyid('kuan').value;thismovie('update').height=document.getelementbyid('gao').value;">
      </label>
      <br>
<br>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="408" height="320" id="update" align="middle">
<param name="allowfullscreen" value="false" />
    <param name="allowscriptaccess" value="always" />
 <param name="movie" value="update.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <embed src="update.swf" quality="high" bgcolor="#ffffff" width="408" height="320" name="update" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
 </object>
<div id="show" style="margin-top:20px; width:500px; text-align:left;"></div>
</body>
</html>

php处理文件

<?php
// 注意:使用组件上传,不可以使用 $_files["filedata"]["type"] 来判断文件类型
mb_http_input("utf-8");
mb_http_output("utf-8");

//---------------------------------------------------------------------------------------------
//组件设置a.md5file为2,3时 的实例代码

if(getget('access2008_cmd')=='2'){ // 提交md5验证后的文件信息进行验证
 //getget("access2008_file_name")  '文件名
 //getget("access2008_file_size") '文件大小,单位字节
 //getget("access2008_file_type") '文件类型 例如.gif .png
 //getget("access2008_file_md5")  '文件的md5签名
 
 die('0'); //返回命令  0 = 开始上传文件, 2 = 不上传文件,前台直接显示上传完成
}
if(getget('access2008_cmd')=='3'){ //提交文件信息进行验证
 //getget("access2008_file_name")  '文件名
 //getget("access2008_file_size") '文件大小,单位字节
 //getget("access2008_file_type") '文件类型 例如.gif .png
 
 die('1'); //返回命令 0 = 开始上传文件,1 = 提交md5验证后的文件信息进行验证, 2 = 不上传文件,前台直接显示上传完成
}
//---------------------------------------------------------------------------------------------

$type=filekzm($_files["filedata"]["name"]);
if ((($type == ".gif")
|| ($type == ".png")
|| ($type == ".jpeg")
|| ($type == ".jpg")
|| ($type == ".bmp"))
&& ($_files["filedata"]["size"] < 200000))
  {
  if ($_files["filedata"]["error"] > 0)
    {
    echo "返回错误: " . $_files["filedata"]["error"] . "<br />";
    }
  else
    {
    echo "上传的文件: " . $_files["filedata"]["name"] . "<br />";
    echo "文件类型: " . $type . "<br />";
    echo "文件大小: " . ($_files["filedata"]["size"] / 1024) . " kb<br />";
    echo "临时文件: " . $_files["filedata"]["tmp_name"] . "<br />";

    if (file_exists( $_files["filedata"]["name"]))
      {
      echo $_files["filedata"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_files["filedata"]["tmp_name"],
      './'.$_files["filedata"]["name"]);
      echo "stored in: " . $_files["filedata"]["name"]."<br />";
   echo "md5效验:".getget("access2008_file_md5")."<br />";
   echo "<br />上传成功!你选择的是<font color='#ff0000'>".getpost("select")."</font>--<font color='#0000ff'>".getpost("select2")."</font>";
      }
    }
  }
else
  {
  echo "上传失败,请检查文件类型和文件大小是否符合标准<br />文件类型:".$type.'<br />文件大小:'.($_files["filedata"]["size"] / 1024) . " kb";
  }
 
function filekzm($a)
{
 $c=strrchr($a,'.');
 if($c)
 {
  return $c;
 }else{
  return '';
 }
}

function getget($v)// 获取get
{
  if(isset($_get[$v]))
  {
  return $_get[$v];
  }else{
  return '';
  }
}

function getpost($v)// 获取post
{
  if(isset($_post[$v]))
  {
   return $_post[$v];
  }else{
   return '';
  }
}
?>

源码包下载
http://down.111cn.net/php/2011/0311/22880.html

[!--infotagslink--]

相关文章

  • php正确禁用eval函数与误区介绍

    eval函数在php中是一个函数并不是系统组件函数,我们在php.ini中的disable_functions是无法禁止它的,因这他不是一个php_function哦。 eval()针对php安全来说具有很...2016-11-25
  • php中eval()函数操作数组的方法

    在php中eval是一个函数并且不能直接禁用了,但eval函数又相当的危险了经常会出现一些问题了,今天我们就一起来看看eval函数对数组的操作 例子, <?php $data="array...2016-11-25
  • php KindEditor文章内分页的实例方法

    我们这里介绍php与KindEditor编辑器使用时如何利用KindEditor编辑器的分页功能实现文章内容分页,KindEditor编辑器在我们点击分页时会插入代码,我们只要以它为分切符,就...2016-11-25
  • Python astype(np.float)函数使用方法解析

    这篇文章主要介绍了Python astype(np.float)函数使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-06-08
  • 自己动手写的jquery分页控件(非常简单实用)

    最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
  • Python中的imread()函数用法说明

    这篇文章主要介绍了Python中的imread()函数用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-16
  • C# 中如何取绝对值函数

    本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
  • C#学习笔记- 随机函数Random()的用法详解

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • jquery实现的伪分页效果代码

    本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
  • 金额阿拉伯数字转换为中文的自定义函数

    CREATE FUNCTION ChangeBigSmall (@ChangeMoney money) RETURNS VarChar(100) AS BEGIN Declare @String1 char(20) Declare @String2 char...2016-11-25
  • C++中 Sort函数详细解析

    这篇文章主要介绍了C++中Sort函数详细解析,sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变...2022-08-18
  • Android开发中findViewById()函数用法与简化

    findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20
  • PHP用strstr()函数阻止垃圾评论(通过判断a标记)

    strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。语法:strstr(string,search)参数string,必需。规定被搜索的字符串。 参数sea...2013-10-04
  • PHP函数分享之curl方式取得数据、模拟登陆、POST数据

    废话不多说直接上代码复制代码 代码如下:/********************** curl 系列 ***********************///直接通过curl方式取得数据(包含POST、HEADER等)/* * $url: 如果非数组,则为http;如是数组,则为https * $header:...2014-06-07
  • php中的foreach函数的2种用法

    Foreach 函数(PHP4/PHP5)foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。...2013-09-28
  • C语言中free函数的使用详解

    free函数是释放之前某一次malloc函数申请的空间,而且只是释放空间,并不改变指针的值。下面我们就来详细探讨下...2020-04-25
  • vue.js 表格分页ajax 异步加载数据

    Vue.js通过简洁的API提供高效的数据绑定和灵活的组件系统.这篇文章主要介绍了vue.js 表格分页ajax 异步加载数据的相关资料,需要的朋友可以参考下...2016-10-20
  • PHP函数strip_tags的一个bug浅析

    PHP 函数 strip_tags 提供了从字符串中去除 HTML 和 PHP 标记的功能,该函数尝试返回给定的字符串 str 去除空字符、HTML 和 PHP 标记后的结果。由于 strip_tags() 无法实际验证 HTML,不完整或者破损标签将导致更多的数...2014-05-31
  • SQL Server中row_number函数的常见用法示例详解

    这篇文章主要给大家介绍了关于SQL Server中row_number函数的常见用法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-12-08
  • PHP加密解密函数详解

    分享一个PHP加密解密的函数,此函数实现了对部分变量值的加密的功能。 加密代码如下: /* *功能:对字符串进行加密处理 *参数一:需要加密的内容 *参数二:密钥 */ function passport_encrypt($str,$key){ //加密函数 srand(...2015-10-30