两款实用php分页代码

 更新时间:2016年11月25日 15:52  点击:1950
分页的就是根据符合条件的总记录除上每页显示的记录就等页数,原理相当简单了公式为 $total = ceil($toalRecord / $perpageNum);

function outpege($ps教程,$page)
{
// $ps 累计信息数 $page 当前page数 $max 列表的最大数 $min 列表的最小值
$max      = ($page >= 5)? $page+5:10;
if($max > $ps)$max =$ps;
$min      =($page-5);
if($min<1) $min =1;
if($page>1)$pagelist = "<a href="?page=1">首页</a>";
for($i=$min;$i<=$max;$i++){
  $pagelist.= ($i!=$page)? "<a href="?page={$i}">{$i}</a>":"<a href="#">{$page}</a>";
}
$pagelist.= ($page>=$ps)?'':"<a href="?page={$ps}">尾页</a>";
return $pagelist;
}

分页代码二

// 分页, {总记录数,每页显示数,当前页,最多显示多少页,分页url}

function page($toalrecord, $perpagenum, $curpage, $url) {
        $total = ceil($toalrecord / $perpagenum);
        $pagearr = array_slice(range(1, $total), max(0, $curpage - ~~($perpagenum / 2)), $perpagenum);
        if($pagearr[0] != 1) {
                array_unshift($pagearr, sprintf("<a href='{$url}%s'><<</a>", $pagearr[0] - 1));
        }
        if($pagearr[count($pagearr)-1] != $total) {
                array_push($pagearr, sprintf("<a href='{$url}%s'>>></a>", $pagearr[count($pagearr)-1] + 1));
        }
        foreach ( $pagearr as $i => &$v ) {
                $v = is_numeric($v) ? "<a href='{$url}{$v}'>{$v}</a>" : $v;
        }
        return "<a href='{$url}'>首页</a>" . implode('', $pagearr) . "<a href='{$url}" . $total . "'>尾页</a>";
}

调用

page(99/*总记录*/, 9/*每页显示数*/, page/*当前页,从1开始*/, 'http://www.111cn.net/?page='/*url前缀*/);

//session.inc.php教程文件:定义session的文件存储,session解决方案,就是要提供在php脚本中定义全局变量的方法,使得这个全局变量在同一个session中对于所有的php脚本都有效。上面我们提到了,session不是一个简单的时间概念,一个session中还包括了特定的用户和服务器。因此更详细地讲,在一个session定义的全局变量的作用范围,是指这个session所对应的用户所访问的所有php。   例如a用户通过session定义了一个全局变量$user=“wind”中,而b用户通过session定义的全局变量$user=“jane”。那么在a用户所访问的php脚本中,$user的值就是wind。php如何创建session
  开始介绍如何创建 session。非常简单,真的。   启动 session 会话,并创建一个 $admin 变量:   // 启动 session   session_start();   // 声明一个名为 admin 的变量,并赋空值。   $_session["admin"] = null;   ?>   如果你使用了 seesion,或者该 php 文件要调用 session 变量,那么就必须在调用 session 之前启动它,使用 session_start() 函数。其它都不需要你设置了,php 自动完成 session 文件的创建。   执行完这个程序后,我们可以到系统临时文件夹找到这个 session 文件,一般文件名形如:sess_4c83638b3b0dbf65583181c2f89168ec,后面是 32 位编码后的随机字符串。用编辑器打开它,看一下它的内容:   admin|n;

<?php


//定义一个超全局数组

$_session = array();

//定义文件句柄

$fp = null;


//用户自定义的开启session函数

function session_file_start() {

 

//1. 首先判断浏览器有没有发送cookie值

if (isset($_cookie['fileid'])) {

 

//2. 接收cookie值

$filename = $_cookie['fileid'];


//3. 打开文件,用于读写

if (file_exists($filename)) {

$globals['fp'] = fopen($filename, 'r+');

} else {

$globals['fp'] = fopen($filename, 'w+');

}


} else {

 

//2. 设置一个文件,并把该文件名放到cookie中

$filename = date('ymdhis');

setcookie('fileid', $filename, time()+60*60*24);


//3. 打开文件,用于读写

$globals['fp'] = fopen($filename, 'w+');


} //end of if-else


//4. 把文件中的数据存储到超全局数组$_session中

while (!feof($globals['fp'])) {

//读取文件中的一行

$buffer = fgets($globals['fp']);

//处理所读取的这一行

$tmparr = explode('=', trim($buffer, 'rn'));


//添加到session数组中

if (count($tmparr) == 2) {

$globals['_session'][$tmparr[0]] = $tmparr[1];

}

} //end of while


} //end of session_file_start()


//注册会话变量的函数

function session_file_register($key, $val) {

 

//设定session变量

$globals['_session'][$key] = $val;


//把该变量放到文件中

fseek($globals['fp'], 0, seek_end);

fwrite($globals['fp'], "$key=$valrn");


} //end of session_file_register()


//结束会话变量

function session_file_destroy() {

 

//1. 关闭文件指针

fclose($globals['fp']);

$fp = null;


//2. 设置session数组为空

$globals['_session'] = array();


} //end of session_file_destroy()

//测试代码文件:1.php
<?php

//确定编码格式

header('content-type: text/html; charset=utf-8');


include("session-file.php");


//测试函数:

//开启会话

session_file_start();


//注册会话变量

$key = 'username';

$val = 'lsl';

session_file_register($key, $val);


session_file_register('username', 'lisa');


//打印session数组

echo $_session['username'];

 


?>

<a href="2.php">下一页</a>


//测试文件:2.php
<?php

//确定编码格式

header('content-type: text/html; charset=utf-8');


include("session-file.php");


//测试函数:

//开启会话

session_file_start();


echo $_session['username'];


?>

关于文件上传我们讲了很多,这只是一款最基本的简单的文件上传功能,同时本教程也介绍了关于上传的原理以及各种函数的使用与file的参数说明,以及php.ihi设置上传文件大小配置等。

1  如果实现小文件的上传(2mb)一下是不需要对php教程.ini 中的配置进行修改的,如果要是大文件的上传就必须进行配置的修改

2 修改php.ini 中的内容有:

       post_max_size 指php通过表单post所能接收的最大值

       upload_max_filesize 指允许上传文件的最大值 

3 上传表单的设置

       <form  method=”post”  action=””  enctype=”multipart/form-data”>

          <input  name=”upfile”  type=”file”>

          <input  type=”hidden”  name=”max_file_size”  value=”1024000”>

       </form>

      解释: 1首先上传时entype属性必须设为multipart/form-data

             2 表单中最好加上 hidden隐藏域 name值为max_file_size  ,该隐藏域的作用不是真正去限制上传文件大小的,而是为了避免用户误传大文件而陷入无尽的等待中。 真正限制大小的还是刚才php.ini 中的两个修改项。

4 预定义变量$_files

         首先他是一个二维的数组,

          $_files[‘upfile’][‘name’]  上传文件的文件名

          $_files[‘upfile’][‘size’]   上传文件的大小

          $_files[‘upfile’][‘tmp_name’]  文件上传时,文件首先被保存为临时文件,改文件是临时文件名

          $_files[‘upfile’][‘type’]   上传文件的类型

          $_files[‘upfile’][‘error’]   错误代码

 

注意 $_files[‘upfile’][‘name’]  这里的upfile 是与表单<input  name=”upfile”  type=”file”> 的name对应,千万别错


5 具体实现 

 

  <?

     $filename=$_files['upfile']['name'];

        $tmp=$_files['upfile']['tmp_name'];

        $error=$_files['upfile']['error'];

        $path="./images/";

        if($error==0){

            if(is_uploaded_file($tmp)){

                  if(move_uploaded_file($tmp,$path.$filename)){

                          echo "上传成功!";

 

                     }else{

                          echo "<script> alert('文件不合法');history.go(-1);</script>";

 

                     }

 


               }else{

                  echo "<script> alert('非法操作!');history.go(-1);</script>";

 

               }


        }else{

 

               echo"<script> alert('上传错误,错误类型:".$error."');history.go(-1);</script>";

 

        }

 

?>

 

 

以前我们的购物车都是点击打开网页,都是web 2.0形式的,本文章提供这款php教程 ajax拖动购物车源码,可以拖动商品放在购物车里面,这样更好的适合用户习惯了。
*/
//download by http://www.111cn.net

/* database config */

$db_host  = 'localhost';
$db_user  = 'root';
$db_pass  = 'dcfan2006';
$db_database = 'test';

$link = mysql教程_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');
mysql_select_db($db_database,$link);
mysql_query("set names utf8");

?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>php ajax拖动购物车源码</title>
<script type="text/网页特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>

<script>
var purchased=new array();
var totalprice=0;

$(document).ready(function(){
 
 $('.product').simpletip({
  
  offset:[40,0],
  content:'<img src="img/ajax_load.gif" alt="loading" style="margin:10px;" />',
  onshow: function(){
   
   var param = this.getparent().find('img').attr('src');
   
   if($.browser.msie && $.browser.version=='6.0')
   {
    param = this.getparent().find('img').attr('style').match(/src="([^"]+)"/);
    param = param[1];
   }
   
   this.load('ajax/tips教程.php',{img:param});
  }

 });
 
 $(".product img").draggable({
 
 containment: 'document',
 opacity: 0.6,
 revert: 'invalid',
 helper: 'clone',
 zindex: 100
 
 });

 $("div.content.drop-here").droppable({
 
   drop:
     function(e, ui)
     {
      var param = $(ui.draggable).attr('src');
      
      if($.browser.msie && $.browser.version=='6.0')
      {
       param = $(ui.draggable).attr('style').match(/src="([^"]+)"/);
       param = param[1];
      }

      addlist(param);
     }
 
 });

});


function addlist(param)
{
 $.ajax({
 type: "post",
 url: "ajax/addtocart.php",
 data: 'img='+encodeuricomponent(param),
 datatype: 'json',
 beforesend: function(x){$('#ajax-loader').css教程('visibility','visible');},
 success: function(msg){
  
  $('#ajax-loader').css('visibility','hidden');
  if(parseint(msg.status)!=1)
  {
   return false;
  }
  else
  {
   var check=false;
   var cnt = false;
   
   for(var i=0; i<purchased.length;i++)
   {
    if(purchased[i].id==msg.id)
    {
     check=true;
     cnt=purchased[i].cnt;
     
     break;
    }
   }
   
   if(!cnt)
    $('#item-list').append(msg.txt);
    
   if(!check)
   {
    purchased.push({id:msg.id,cnt:1,price:msg.price});
   }
   else
   {
    if(cnt>=3) return false;
    
    purchased[i].cnt++;
    $('#'+msg.id+'_cnt').val(purchased[i].cnt);
   }
   
   totalprice+=msg.price;
   update_total();

  }
  
  $('.tooltip').hide();
 
 }
 });
}

function findpos(id)
{
 for(var i=0; i<purchased.length;i++)
 {
  if(purchased[i].id==id)
   return i;
 }
 
 return false;
}

function remove(id)
{
 var i=findpos(id);

 totalprice-=purchased[i].price*purchased[i].cnt;
 purchased[i].cnt = 0;

 $('#table_'+id).remove();
 update_total();
}

function change(id)
{
 var i=findpos(id);
 
 totalprice+=(parseint($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price;
 
 purchased[i].cnt=parseint($('#'+id+'_cnt').val());
 update_total();
}

function update_total()
{
 if(totalprice)
 {
  $('#total').html('total: $'+totalprice);
  $('a.button').css('display','block');
 }
 else
 {
  $('#total').html('');
  $('a.button').hide();
 }
}
</script>
<style>
body,h1,h2,h3,p,td,quote,small,form,input,ul,li,ol,label{
 margin:0px;
 padding:0px;
 font-family:arial, helvetica, sans-serif;
}

body{
 color:#555555;
 font-size:13px;
 background-color:#282828;
}

.clear{
 clear:both;
}

#main-container{
 width:700px;
 margin:20px auto;
}

.container{
 margin-bottom:40px;
}

.top-label{
 background:url(img/label_bg.png) no-repeat;
 display:inline-block;
 margin-left:20px;
 position:relative;
 margin-bottom:-15px;
}

.label-txt{
 background:url(img/label_bg.png) no-repeat top right;
 display:inline-block;
 font-size:10px;
 height:36px;
 margin-left:10px;
 padding:12px 15px 0 5px;
 text-transform:uppercase;
}

.content-area{
 background:url(img/container_top.png) no-repeat #fcfcfc;
 padding:15px 20px 0 20px;
}

.content{
 padding:10px;
}

.drag-desired{
 background:url(img/drag_desired_label.png) no-repeat top right;
 padding:30px;
}

.drop-here{
 background:url(img/drop_here_label.png) no-repeat top right;
}


.bottom-container-border{
 background:url(img/container_bottom.png) no-repeat;
 height:14px;
}

.product{
 border:2px solid #f5f5f5;
 float:left;
 margin:15px;
 padding:10px;
}

.product img{
 cursor:move;
}

p.descr{
 padding:5px 0;
}

small{
 display:block;
 margin-top:4px;
}

.tooltip{
 position: absolute;
 top: 0;
 left: 0;
 z-index: 3;
 display: none;

 background-color:#666666;
 border:1px solid #666666;
 color:#fcfcfc;

 padding:10px;
 
 -moz-border-radius:12px;
 -khtml-border-radius: 12px;
 -webkit-border-radius: 12px;
 border-radius:12px;
}

#cart-icon{
 width:128px;
 float:left;
 position:relative;
}

#ajax-loader{
 position:absolute;
 top:0px;
 left:0px;
 visibility:hidden;
}

#item-list{
 float:left;
 width:490px;
 margin-left:20px;
 padding-top:15px;
}

a.remove,a.remove:visited{
 color:red;
 font-size:10px;
 text-transform:uppercase;
}

#total{
 clear:both;
 float:right;
 font-size:10px;
 font-weight:bold;
 padding:10px 12px;
 text-transform:uppercase;
}

#item-list table{
 background-color:#f7f7f7;
 border:1px solid #efefef;
 margin-top:5px;
 padding:4px;
}

a.button,a.button:visited{
 display:none;

 height:29px;
 width:136px;

 padding-top:15px;
 margin:0 auto;
 overflow:hidden;

 color:white; 
 font-size:12px;
 font-weight:bold;
 text-align:center;
 text-transform:uppercase;
 
 background:url(img/button.png) no-repeat center top;
}

a.button:hover{
 background-position:bottom;
 text-decoration:none;
}


a, a:visited {
 color:#00bbff;
 text-decoration:none;
 outline:none;
}

a:hover{
 text-decoration:underline;
}

h1{
 font-size:28px;
 font-weight:bold;
 font-family:"trebuchet ms",arial, helvetica, sans-serif;
}

h2{
 font-weight:normal;
 font-size:20px;
 
 color:#666666;
 text-indent:30px;
 margin:20px 0;
}

.tutorialzine h1{
 color:white;
 margin-bottom:10px;
 font-size:48px;
}

.tutorialzine h3{
 color:#f5f5f5;
 font-size:10px;
 font-weight:bold;
 margin-bottom:30px;
 text-transform:uppercase;
}

.tutorial-info{
 color:white;
 text-align:center;
 padding:10px;
 margin-top:-20px;
}

</style>

<!--[if lt ie 7]>
<style type="text/css">
 .pngfix { behavior: url(pngfix/iepngfix.htc);}
    .tooltip{width:200px;};
</style>
<![endif]-->

</head>

<body>
<div id="main-container">

 <div class="tutorialzine">
    <h1>shopping cart</h1>
    <h3>the best products at the best prices</h3>
    </div>


    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">products</span>
        </span>
       
        <div class="content-area">
   
      <div class="content drag-desired">
             
                <?php

    $result = mysql_query("select * from internet_shop");
    while($row=mysql_fetch_assoc($result))
    {
     echo '<div class="product"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></div>';
    }

    ?>
               
               
                <div class="clear"></div>
            </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>

 

    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">shopping cart</span>
        </span>
       
        <div class="content-area">
   
      <div class="content drop-here">
             <div id="cart-icon">
              <img src="img/shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" />
     <img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" />
                </div>

    <form name="checkoutform" method="post" action="order.php">
               
                <div id="item-list">
                </div>
               
    </form>               
                <div class="clear"></div>

    <div id="total"></div>

                <div class="clear"></div>
               
                <a href="" onclick="document.forms.checkoutform.submit(); return false;" class="button">checkout</a>
               
          </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>
 
</div>
</body>
</html>

tips.php

<?php

 

if(!$_post['img']) die("there is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_post['img'])));

$row=mysql_fetch_assoc(mysql_query("select * from internet_shop where img='".$img."'"));

if(!$row) die("there is no such product!");

echo '<strong>'.$row['name'].'</strong>

<p class="descr">'.$row['description'].'</p>

<strong>price: $'.$row['price'].'</strong>
<small>drag it to your shopping cart to purchase it</small>';
?>

addtocard.php加入购物车

<?php

define('include_check',1);
require "../connect.php";

if(!$_post['img']) die("there is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_post['img'])));
$row=mysql_fetch_assoc(mysql_query("select * from internet_shop where img='".$img."'"));

echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:'

<table width="100%" id="table_'.$row['id'].'">
  <tr>
    <td width="60%">'.$row['name'].'</td>
    <td width="10%">$'.$row['price'].'</td>
    <td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option></slect>
 
 </td>
 <td width="15%"><a href="#" onclick="remove('.$row['id'].');return false;" class="remove">remove</a></td>
  </tr>
</table>'}';
?>

查看购物车页面

<div id="main-container">

    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">your order</span>
        </span>
       
        <div class="content-area">
   
      <div class="content">
             
                <?php
    
    $cnt = array();
    $products = array();
    
    foreach($_post as $key=>$value)
    {
     $key=(int)str_replace('_cnt','',$key);
    
     $products[]=$key;
     $cnt[$key]=$value;
    }

    $result = mysql_query("select * from internet_shop where id in(".join($products,',').")");
    
    if(!mysql_num_rows($result))
    {
     echo '<h1>there was an error with your order!</h1>';
    }
    else
    {
     echo '<h1>you ordered:</h1>';
     
     while($row=mysql_fetch_assoc($result))
     {
      echo '<h2>'.$cnt[$row['id']].' x '.$row['name'].'</h2>';
      
      $total+=$cnt[$row['id']]*$row['price'];
     }
  
     echo '<h1>total: $'.$total.'</h1>';
    }
    ?>
               
               
                <div class="clear"></div>
            </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>

</div>

源码下载地址。
http://down.111cn.net/down/code/php/qitayuanma/2010/1102/21586.html

在 用户注册检测用户名是否存在我们要提供告诉用户你要注册的用户名是否可用,那么我们就得利用ajax技术来实例,下面是一款ajax php当用户输入完用户名时提示用户是否可用用的代码

<!--
t.php代码

 代码如下 复制代码

<?
$title = isset($_get['title'])?$_get['title']:'';
if( $title )
{
 $sql ='select id from filecontent where title=''.$title.''';
 $q = mysql教程_query( $sql ) or die( mysql_error());
 if( mysql_num_rows( $q )  )
 {
  echo 1;
 }
 else
 {
  echo 0;
 }
}
else
{
 echo 0;
}
?>

 

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title> 用户注册检测用户名是否存在ajax + php代码</title>
<script>
//  用户注册检测用户名是否存在ajax + php代码


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 getrenews(value){//主调函数
 var xmlhttp=createxmlhttprequest();
 var url = "t.php?action=check&title="+value+"&mt="+math.random(300000);
 if (value==""){  
  return false ;
 }
 if (xmlhttp){
  callback = getreadystatehandler(xmlhttp);
  xmlhttp.onreadystatechange = callback;
  xmlhttp.open("get", url,true);
  xmlhttp.send(null);
 }
}
//返回0代表用户名可用,否则提示己被注册。

function getreadystatehandler(xmlhttp){//服务器返回后处理函数
 return function (){
  if(xmlhttp.readystate == 4){
   if(xmlhttp.status == 200){
       
     
     if (xmlhttp.responsetext==1){
       document.getelementbyid("checkid").innerhtml="<font color='red'>对不起,你输入的用户名己被注册!</font>";     
     }else{
      document.getelementbyid("checkid").innerhtml="可以注册";     
     }      
   }
  }
 }
}
</script>
</head>

<body>
给input框增加onblur事件,当用户输入完用户名就检测用户名,并给出提示。
输入用户名<input name="title" type="text" id="title" size="40" onblur="getrenews(this.value);"><span id="checkid"></span>
</body>
</html>

[!--infotagslink--]

相关文章

  • php KindEditor文章内分页的实例方法

    我们这里介绍php与KindEditor编辑器使用时如何利用KindEditor编辑器的分页功能实现文章内容分页,KindEditor编辑器在我们点击分页时会插入代码,我们只要以它为分切符,就...2016-11-25
  • 自己动手写的jquery分页控件(非常简单实用)

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

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • 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
  • jquery实现的伪分页效果代码

    本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
  • 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
  • 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
  • vue.js 表格分页ajax 异步加载数据

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

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
  • js实现跨域的4种实用方法原理分析

    什么是js跨域呐?js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据。只要协议、域名、端口有任何一个不同,都被当作是不同的域。要...2015-10-30
  • php导出csv格式数据并将数字转换成文本的思路以及代码分享

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