php shtml生成类带使用方法

 更新时间:2016年11月25日 16:29  点击:1819

<?php
 class Shtml{
  var $DataSource;        //array
  var $Templet;           //string
  var $FileName;
  
  //绑定数据源
  function BindData($arr){
   $this->DataSource = $arr;
  }
  
  function Create(){
  //只谈思路,自己写:
   $tmp = $this->Templet;
   foreach($this->DataSource as $key=>$value){
  //替换模板字符串中<FIELD_$key> 的字符串
    $tmp = str_replace('<FIELD_'.$key.'>',$value,$tmp);
   }
  //生成文件,存盘。
   $fp = fopen($this->FileName,'w');
   if (fwrite ($fp,$tmp)){
    fclose ($fp);
   }else {
    fclose ($fp);
   }
  }
 }
 
 //用法:
 /*$arr = array();
 $arr["title"] = "这里是标题";
 $arr["content"] = "这里是内容";
 $obj = new Shtml;
 $obj->FileName="xxx.htm";
 $obj->Templet="标题:<FIELD_title>内容:<FIELD_content>";
 $obj->BindData($arr);
 //一切OK,万事达吉
 $obj->Create();*/
?>

 class SubPages{
  private   $each_disNums;//每页显示的条目数
  private   $nums;//总条目数
  private   $current_page;//当前被选中的页
  private   $sub_pages;//每次显示的页数
  private   $pageNums;//总页数
  private   $page_array = array();//用来构造分页的数组
  private   $subPage_link;//每个分页的链接
  private   $subPage_type;//显示分页的类型
     /*
     __construct是SubPages的构造函数,用来在创建类的时候自动运行.
     @$each_disNums   每页显示的条目数
     @nums     总条目数
     @current_num     当前被选中的页
     @sub_pages       每次显示的页数
     @subPage_link    每个分页的链接
     @subPage_type    显示分页的类型
   
     当@subPage_type=1的时候为普通分页模式
     example:   共4523条记录,每页显示10条,当前第1/453页 [首页] [上页] [下页] [尾页]
     当@subPage_type=2的时候为经典分页样式
     example:   当前第1/453页 [首页] [上页] 1 2 3 4 5 6 7 8 9 10 [下页] [尾页]
     */
  function __construct($each_disNums,$nums,$current_page,$sub_pages,$subPage_link,$subPage_type){
   $this->each_disNums=intval($each_disNums);
   $this->nums=intval($nums);
   if(!$current_page){
    $this->current_page=1;
   }else{
    $this->current_page=intval($current_page);
   }
   $this->sub_pages=intval($sub_pages);
   $this->pageNums=ceil($nums/$each_disNums);
   $this->subPage_link=$subPage_link;
   $this->show_SubPages($subPage_type);     //调用show_SubPages函数
    //echo $this->pageNums."--".$this->sub_pages;
  }
  function __destruct(){
   unset($each_disNums);
   unset($nums);
   unset($current_page);
   unset($sub_pages);
   unset($pageNums);
   unset($page_array);
   unset($subPage_link);
   unset($subPage_type);
  }
   /*
   show_SubPages函数用在构造函数里面。而且用来判断显示什么样子的分页 
     */
  function show_SubPages($subPage_type){
   if($subPage_type == 1){
    $this->subPageCss1();
   }elseif ($subPage_type == 2){
    $this->subPageCss2();
   }
  }
   
   
     /*
   用来给建立分页的数组初始化的函数。
     */
  function initArray(){
   for($i=0;$i<$this->sub_pages;$i++){
    $this->page_array[$i]=$i;
   }
   return $this->page_array;
  }
   /*
   construct_num_Page该函数使用来构造显示的条目
   即使:[1][2][3][4][5][6][7][8][9][10]
     */
  function construct_num_Page(){
   if($this->pageNums < $this->sub_pages){
    $current_array=array();
    for($i=0;$i<$this->pageNums;$i++){
     $current_array[$i]=$i+1;
    }
   }else{
    $current_array=$this->initArray();
    if($this->current_page <= 3){
     for($i=0;$i<count($current_array);$i++){
      $current_array[$i]=$i+1;
     }
    }elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1 ){
     for($i=0;$i<count($current_array);$i++){
      $current_array[$i]=($this->pageNums)-($this->sub_pages)+1+$i;
     }
    }else{
     for($i=0;$i<count($current_array);$i++){
      $current_array[$i]=$this->current_page-2+$i;
     }
    }
   }   
   return $current_array;
  }
   /*
     构造普通模式的分页
     共4523条记录,每页显示10条,当前第1/453页 [首页] [上页] [下页] [尾页]
     */
  function subPageCss1(){
   $subPageCss1Str="";
   $subPageCss1Str.="共".$this->nums."条记录,";
   $subPageCss1Str.="每页显示".$this->each_disNums."条,";
   $subPageCss1Str.="当前第".$this->current_page."/".$this->pageNums."页 ";
   if($this->current_page > 1){
    $firstPageUrl=$this->subPage_link."1";
    $prewPageUrl=$this->subPage_link.($this->current_page-1);
    $subPageCss1Str.="[<a href='$firstPageUrl'>首页</a>] ";
    $subPageCss1Str.="[<a href='$prewPageUrl'>上一页</a>] ";
   }else {
    $subPageCss1Str.="[首页] ";
    $subPageCss1Str.="[上一页] ";
   }
     
   if($this->current_page < $this->pageNums){
    $lastPageUrl=$this->subPage_link.$this->pageNums;
    $nextPageUrl=$this->subPage_link.($this->current_page+1);
    $subPageCss1Str.=" [<a href='$nextPageUrl'>下一页</a>] ";
    $subPageCss1Str.="[<a href='$lastPageUrl'>尾页</a>] ";
   }else {
    $subPageCss1Str.="[下一页] ";
    $subPageCss1Str.="[尾页] ";
   }  
   echo $subPageCss1Str;  
  }
   
   /*
     构造经典模式的分页
     当前第1/453页 [首页] [上页] 1 2 3 4 5 6 7 8 9 10 [下页] [尾页]
     *//* 产品页用*/
  function subPageCss2(){
   $subPageCss2Str="";
   
   //jason edit
   //$subPageCss2Str.="<li class="text">当前第".$this->current_page."/".$this->pageNums."页 </li>";
     
   if($this->current_page > 1){
    $firstPageUrl=$this->subPage_link."1";
    $prewPageUrl=$this->subPage_link.($this->current_page-1);
    //$subPageCss2Str.="<li class="pre"><a href='$firstPageUrl'>首 页</a></li>";
    $subPageCss2Str.="<li class="pre"><a href='$prewPageUrl'>上一页</a></li>";
   }else {
    //$subPageCss2Str.="<li class="prea">首 页</li> ";
    $subPageCss2Str.="<li class="prea">上一页</li> ";
   }
     
   $a=$this->construct_num_Page();
   for($i=0;$i<count($a);$i++){
    $s = $a[$i];
    if($s == $this->current_page ){
     $subPageCss2Str.="<li class="num">".$s."</li>";
    }else{
     $url=$this->subPage_link.$s;
     //echo $url;exit;
     $subPageCss2Str.="<li class="num2"><a href='$url'>".$s."</a></li>";
     //echo $subPageCss2Str;
    }
   }
   //exit;
   if($this->current_page < $this->pageNums){
    $lastPageUrl=$this->subPage_link.$this->pageNums;
    $nextPageUrl=$this->subPage_link.($this->current_page+1);
    $subPageCss2Str.=" <li class="next"><a href='$nextPageUrl'>下一页</a></li> ";
    //$subPageCss2Str.="<li class="next"><a href='$lastPageUrl'>尾 页</a></li> ";
   }else {
    $subPageCss2Str.="<li class="nexta">下一页</li>";
    //$subPageCss2Str.="<li class="nexta">尾 页</li> ";
   }
   echo $subPageCss2Str;
  }
 }

class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* Private Variables */
var $sock;

/* Constractor */
function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
 $this->debug = FALSE;
 $this->smtp_port = $smtp_port;
 $this->relay_host = $relay_host;
 $this->time_out = 30; //is used in fsockopen()
 $this->auth = $auth;//auth
 $this->user = $user;
 $this->pass = $pass;
 $this->host_name = "localhost"; //is used in HELO command
 $this->log_file = "";
 $this->sock = FALSE;
}

/* Main Function */
function sendmail($to, $from ,$fromname, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = ""){
 $mail_from = $this->get_address($this->strip_comment($from));
 $body = ereg_replace("(^|( ))(.)", ".", $body);
 $header .= "MIME-Version:1.0 ";
 if($mailtype=="HTML"){
  $header .= "Content-Type:text/html;charset=utf-8 ";
 }
 $header .= "To: ".$to." ";
 if ($cc != ""){
  $header .= "Cc: ".$cc." ";
 }
 $header .= "From: $fromname<".$fromname."> ";
 $header .= "Subject: ".$subject." ";
 $header .= $additional_headers;
 $header .= "Date: ".date("r")." ";
 $header .= "X-Mailer:By Redhat (PHP/".php教程version().") ";
 list($msec, $sec) = explode(" ", microtime());
 $header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from."> ";
 $TO = explode(",", $this->strip_comment($to));

 if ($cc != ""){
  $TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
 }
 if ($bcc != ""){
  $TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
 }
 $sent = TRUE;
 foreach ($TO as $rcpt_to){
  $rcpt_to = $this->get_address($rcpt_to);
  if (!$this->smtp_sockopen($rcpt_to)){
   $this->log_write("Error: Cannot send email to ".$rcpt_to." ");
   $sent = FALSE;
   continue;
  }
  if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)){
   $this->log_write("E-mail has been sent to <".$rcpt_to."> ");
  }else{
   $this->log_write("Error: Cannot send email to <".$rcpt_to."> ");
   $sent = FALSE;
  }
  fclose($this->sock);
  $this->log_write("Disconnected from remote host ");
 }
 return $sent;
}

 /* Private Functions */
 function smtp_send($helo, $from, $to, $header, $body = ""){
  if (!$this->smtp_putcmd("HELO", $helo)){
   return $this->smtp_error("sending HELO command");
  }
  
  #auth
  if($this->auth){
   if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))){
    return $this->smtp_error("sending HELO command");
   }
   if (!$this->smtp_putcmd("", base64_encode($this->pass))){
    return $this->smtp_error("sending HELO command");
   }
  }
  if (!$this->smtp_putcmd("MAIL", "FROM:<".$from.">")){
   return $this->smtp_error("sending MAIL FROM command");
  }
  if (!$this->smtp_putcmd("RCPT", "TO:<".$to.">")){
   return $this->smtp_error("sending RCPT TO command");
  }
  if (!$this->smtp_putcmd("DATA")){
   return $this->smtp_error("sending DATA command");
  }
  if (!$this->smtp_message($header, $body)){
   return $this->smtp_error("sending message");
  }
  if (!$this->smtp_eom()){
   return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]");
  }
  if (!$this->smtp_putcmd("QUIT")){
   return $this->smtp_error("sending QUIT command");
  }
  return TRUE;
 }

 function smtp_sockopen($address){
  if ($this->relay_host == ""){
   return $this->smtp_sockopen_mx($address);
  }
  else{
   return $this->smtp_sockopen_relay();
  }
 }

 function smtp_sockopen_relay(){
  $this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port." ");
  $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
  if (!($this->sock && $this->smtp_ok())){
   $this->log_write("Error: Cannot connenct to relay host ".$this->relay_host." ");
   $this->log_write("Error: ".$errstr." (".$errno.") ");
   return FALSE;
  }
  $this->log_write("Connected to relay host ".$this->relay_host." ");
  return TRUE;;
 }
 
 function smtp_sockopen_mx($address){
  $domain = ereg_replace("^.+@([^@]+)$", "", $address);
  if (!@getmxrr($domain, $MXHOSTS)){
   $this->log_write("Error: Cannot resolve MX "".$domain."" ");
   return FALSE;
  }
  foreach ($MXHOSTS as $host){
   $this->log_write("Trying to ".$host.":".$this->smtp_port." ");
   $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
   if (!($this->sock && $this->smtp_ok())){
    $this->log_write("Warning: Cannot connect to mx host ".$host." ");
    $this->log_write("Error: ".$errstr." (".$errno.") ");
    continue;
   }
   $this->log_write("Connected to mx host ".$host." ");
   return TRUE;
  }
  $this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).") ");
  return FALSE;
 }

 function smtp_message($header, $body){
  fputs($this->sock, $header." ".$body);
  $this->smtp_debug("> ".str_replace(" ", " "."> ", $header." > ".$body." > "));
  return TRUE;
 }
 
 function smtp_eom(){
  fputs($this->sock, " . ");
  $this->smtp_debug(". [EOM] ");
  return $this->smtp_ok();
 }

 function smtp_ok(){
  $response = str_replace(" ", "", fgets($this->sock, 512));
  $this->smtp_debug($response." ");
  if (!ereg("^[23]", $response)){
   fputs($this->sock, "QUIT ");
   fgets($this->sock, 512);
   $this->log_write("Error: Remote host returned "".$response."" ");
   return FALSE;
  }
  return TRUE;
 }

 function smtp_putcmd($cmd, $arg = ""){
  if($arg != ""){
   if($cmd==""){
    $cmd = $arg;
   }
   else{
    $cmd = $cmd." ".$arg;
   }
  }
  fputs($this->sock, $cmd." ");
  $this->smtp_debug("> ".$cmd." ");
  return $this->smtp_ok();
 }

 function smtp_error($string){
  $this->log_write("Error: Error occurred while ".$string.". ");
  return FALSE;
 }

 function log_write($message){
  $this->smtp_debug($message);
  if ($this->log_file == ""){
   return TRUE;
  }
  $message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message;
  if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))){
   $this->smtp_debug("Warning: Cannot open log file "".$this->log_file."" ");
   return FALSE;;
  }
  flock($fp, LOCK_EX);
  fputs($fp, $message);
  fclose($fp);
  return TRUE;
 }

 function strip_comment($address){//去除"()"
  $comment = "([^()]*)";
  while (ereg($comment, $address)){
   $address = ereg_replace($comment, "", $address);
  }
  return $address;
 }

 function get_address($address){
  $address = ereg_replace("([ ])+", "", $address);// 制表符 回车符   换行符  +匹配前面的子表达式一次或多次
  $address = ereg_replace("^.*<(.+)>.*$", "", $address);
  return $address;
 }

 function smtp_debug($message){
  if ($this->debug){
   echo $message;
  }
 }
}

  //--------------------------------------------------
  function GetIndexText($okstr,$ilen=-1)
  {
    if($okstr=="") return "";
    $ws = explode(" ",$okstr);
    $okstr = "";
    $wks = "";
    foreach($ws as $w)
    {
      $w = trim($w);
      //排除小于2的字符
      if(strlen($w)<2) continue;
      //排除数字或日期
      if(!ereg("[^0-9:-]",$w)) continue;
      if(strlen($w)==2&&ord($w[0])>0x80) continue;
      if(isset($wks[$w])) $wks[$w]++;
      else $wks[$w] = 1;
    }
    if(is_array($wks))
    {
      arsort($wks);
      if($ilen==-1)
      { foreach($wks as $w=>$v) $okstr .= $w." "; }
      else
      {
        foreach($wks as $w=>$v){
          if((strlen($okstr)+strlen($w)+1)<$ilen) $okstr .= $w." ";
          else break;
        }
      }
    }
    return trim($okstr);
  }

在您可以使用PHP来管理您的上传,你首先需要建设作为用户界面的HTML表单上传的文

件。有一个在下面的例子外观和保存一个编辑HTML代码。

<html>
<body>
  <form enctype="multipart/form-data" action="upload.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Choose a file to upload: <input name="uploaded_file" type="file" />
    <input type="submit" value="Upload" />
  </form>
</body>
</html>

有一些规则需要建设时遵循HTML表单。首先,请确保该窗体使用POST方法。第二,形

式需要以下属性:字符编码=“多重/表单数据”。它指定的内容类型时使用的信息提

交给伺服器。如果没有这些要求,您的文件上传不了。

另一个需要注意的是隐藏的表单字段名为MAX_FILE_SIZE设置的值。某些Web浏览器实

际上反映了这个领域,也不会允许用户上载文件超过这个数字(字节)更大。您应该

将此值设置为配合最大上传大小,在php.ini文件中设置。这是一套与中

upload_max_filesize,默认值是2MB的。但它仍然不能保证你的脚本将不会转交了尺

寸较大的文件。危险的是,攻击者将尝试向您发送一个请求几个大文件,并填写了文

件系统,也就是PHP存储解码文件。设置在php.ini的post_max_size的指令文件的最大

尺寸,你要(必须大于中upload_max_filesize)。默认值为10MB的。此指令控制的所

有要求,在一个允许的POST数据最大大小。另外,还要确保在你的php.ini文件

file_uploads设置为On。

至少,有一个在输入标记属性看:类型=“文件”。它是用来指定为文件选择控制输入

元素。这提供了一个文件的URI的地方,则需要键入一个“浏览”按钮,可作为替代的

URI输入使用。

在用户进入一个文件的URI,并点击提交按钮的文件的副本将被发送到服务器和用户将

被重定向到upload.php。此PHP文件将处理表单数据。

返回页首

处理表单数据(PHP代码)

当文件被上传和PHP创建了一个文件的临时副本,并建立了超全局变量$ _FILES数组,

包含有关文件的信息。对于每个文件,有5个数据。我们已上传字段命名

为'uploaded_file',所以会存在以下数据:

变量$ _FILES [“uploaded_file”] [“name”]从用户的机器上载的文件的原名称
变量$ _FILES [“uploaded_file”] [“type”]的上传文件的MIME类型(如果浏览器

提供的类型)
变量$ _FILES [“uploaded_file”] [“size”]的以字节为单位上传的文件大小
变量$ _FILES [“uploaded_file”] [“tmp_name”],在该文件暂时存储在服务器上

的位置
变量$ _FILES [“uploaded_file”] [“error”]错误代码从文件上传结果
下面的例子接受一个上传的文件并保存在上载目录中。它允许根据350Kb上传只有JPEG

图像。该代码本身,是相当清楚的,但我们会作出一些解释。有一个例子在外观和保

存此为upload.php PHP代码。
<?php
//Сheck that we have a file
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error']

== 0)) {
  //Check if the file is JPEG image and it's size is less than 350Kb
  $filename = basename($_FILES['uploaded_file']['name']);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg")

&&
    ($_FILES["uploaded_file"]["size"] < 350000)) {
    //Determine the path to which we want to save this file
      $newname = dirname(__FILE__).'/upload/'.$filename;
      //Check if the file with the same name is already exists on the

server
      if (!file_exists($newname)) {
        //Attempt to move the uploaded file to it's new place
        if ((move_uploaded_file($_FILES['uploaded_file']

['tmp_name'],$newname))) {
           echo "It's done! The file has been saved as: ".$newname;
        } else {
           echo "Error: A problem occurred during file upload!";
        }
      } else {
         echo "Error: File ".$_FILES["uploaded_file"]["name"]." already

exists";
      }
  } else {
     echo "Error: Only .jpg images under 350Kb are accepted for upload";
  }
} else {
 echo "Error: No file uploaded";
}
?>
在此之前的上载您需要的文件,以确定文件是否真的上传任何东西。之后我们检查上

传的文件,JPEG图像,其大小小于350Kb的。接下来,我们确定的道路,这是我们要保

存此文件,并检查是否已经存在一个服务器上的这些文件的名称。当所有检查通过,

我们将文件复制到一个永久的位置使用move_upload_file()函数。此功能也证实该

文件你要过程,是一个合法的文件从用户上传结果。如果该文件上传成功,那么相应

的消息将出现。

注意:要确保PHP已经允许读取和写入临时文件中保存的位置是您要复制文件的目录。

这个例子其实很简单,它的提出是为了演示如何使用PHP上传文件。例如,您可以添加

新的条件,并允许上传GIF和PNG图像,或任何文件,您需要其他种类。如果您是本教

程使用PHP不熟悉可能是一个很好的起点。

[!--infotagslink--]

相关文章

  • php 中file_get_contents超时问题的解决方法

    file_get_contents超时我知道最多的原因就是你机器访问远程机器过慢,导致php脚本超时了,但也有其它很多原因,下面我来总结file_get_contents超时问题的解决方法总结。...2016-11-25
  • 图解PHP使用Zend Guard 6.0加密方法教程

    有时为了网站安全和版权问题,会对自己写的php源码进行加密,在php加密技术上最常用的是zend公司的zend guard 加密软件,现在我们来图文讲解一下。 下面就简单说说如何...2016-11-25
  • HTTP 408错误是什么 HTTP 408错误解决方法

    相信很多站长都遇到过这样一个问题,访问页面时出现408错误,下面一聚教程网将为大家介绍408错误出现的原因以及408错误的解决办法。 HTTP 408错误出现原因: HTT...2017-01-22
  • php抓取网站图片并保存的实现方法

    php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
  • Android子控件超出父控件的范围显示出来方法

    下面我们来看一篇关于Android子控件超出父控件的范围显示出来方法,希望这篇文章能够帮助到各位朋友,有碰到此问题的朋友可以进来看看哦。 <RelativeLayout xmlns:an...2016-10-02
  • ps怎么使用HSL面板

    ps软件是现在很多人都会使用到的,HSL面板在ps软件中又有着非常独特的作用。这次文章就给大家介绍下ps怎么使用HSL面板,还不知道使用方法的下面一起来看看。 &#8195;...2017-07-06
  • ps把文字背景变透明的操作方法

    ps软件是现在非常受大家喜欢的一款软件,有着非常不错的使用功能。这次文章就给大家介绍下ps把文字背景变透明的操作方法,喜欢的一起来看看。 1、使用Photoshop软件...2017-07-06
  • intellij idea快速查看当前类中的所有方法(推荐)

    这篇文章主要介绍了intellij idea快速查看当前类中的所有方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-09-02
  • Mysql select语句设置默认值的方法

    1.在没有设置默认值的情况下: 复制代码 代码如下:SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id 结果:...2014-05-31
  • js导出table数据到excel即导出为EXCEL文档的方法

    复制代码 代码如下: <!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 ht...2013-10-13
  • Plesk控制面板新手使用手册总结

    许多的朋友对于Plesk控制面板应用不是非常的了解特别是英文版的Plesk控制面板,在这里小编整理了一些关于Plesk控制面板常用的使用方案整理,具体如下。 本文基于Linu...2016-10-10
  • mysql 批量更新与批量更新多条记录的不同值实现方法

    批量更新mysql更新语句很简单,更新一条数据的某个字段,一般这样写:复制代码 代码如下:UPDATE mytable SET myfield = 'value' WHERE other_field = 'other_value';如果更新同一字段为同一个值,mysql也很简单,修改下where即...2013-10-04
  • js基础知识(公有方法、私有方法、特权方法)

    本文涉及的主题虽然很基础,在许多人看来属于小伎俩,但在JavaScript基础知识中属于一个综合性的话题。这里会涉及到对象属性的封装、原型、构造函数、闭包以及立即执行表达式等知识。公有方法 公有方法就是能被外部访问...2015-11-08
  • ps怎么制作倒影 ps设计倒影的方法

    ps软件是一款非常不错的图片处理软件,有着非常不错的使用效果。这次文章要给大家介绍的是ps怎么制作倒影,一起来看看设计倒影的方法。 用ps怎么做倒影最终效果&#819...2017-07-06
  • 使用insertAfter()方法在现有元素后添加一个新元素

    复制代码 代码如下: //在现有元素后添加一个新元素 function insertAfter(newElement, targetElement){ var parent = targetElement.parentNode; if (parent.lastChild == targetElement){ parent.appendChild(newEl...2014-05-31
  • PHP 验证码不显示只有一个小红叉的解决方法

    最近想自学PHP ,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下 未修改之前,出现如下错误; (1)修改步骤如下,原因如下,原因是apache权限没开, (2)点击打开php.int., 搜索extension=ph...2013-10-04
  • c#中分割字符串的几种方法

    单个字符分割 string s="abcdeabcdeabcde"; string[] sArray=s.Split('c'); foreach(string i in sArray) Console.WriteLine(i.ToString()); 输出下面的结果: ab de...2020-06-25
  • 安卓手机wifi打不开修复教程,安卓手机wifi打不开解决方法

    手机wifi打不开?让小编来告诉你如何解决。还不知道的朋友快来看看。 手机wifi是现在生活中最常用的手机功能,但是遇到手机wifi打不开的情况该怎么办呢?如果手机wifi...2016-12-21
  • 使用percona-toolkit操作MySQL的实用命令小结

    1.pt-archiver 功能介绍: 将mysql数据库中表的记录归档到另外一个表或者文件 用法介绍: pt-archiver [OPTION...] --source DSN --where WHERE 这个工具只是归档旧的数据,不会对线上数据的OLTP查询造成太大影响,你可以将...2015-11-24
  • 使用GruntJS构建Web程序之构建篇

    大概有如下步骤 新建项目Bejs 新建文件package.json 新建文件Gruntfile.js 命令行执行grunt任务 一、新建项目Bejs源码放在src下,该目录有两个js文件,selector.js和ajax.js。编译后代码放在dest,这个grunt会...2014-06-07