php 保存远程服务器图片代码

 更新时间:2016年11月25日 16:03  点击:1519

php 保存远程服务器图片代码
<?php

function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

function SaveHTTPFile($fFileHTTPPath,$fFileSavePath,$fFileSaveName)
{
 //记录程序开始的时间
 $BeginTime=getmicrotime();

 //取得文件名
 $fFileSaveName=$fFileSavePath."/".$fFileSaveName;

 //取得文件的内容
 ob_start();
 readfile($fFileHTTPPath);
 $img = ob_get_contents();
 ob_end_clean();
 //$size = strlen($img);

 //保存到本地
 $fp2=@fopen($fFileSaveName, "a");
 fwrite($fp2,$img);
 fclose($fp2);

 //记录程序运行结束的时间
 $EndTime=getmicrotime();

 //返回运行时间
 return($EndTime-$BeginTime);
}
?>

function cat_options($spec_cat_id$arr)

{

    static 
$cat_options = array();

    if (isset(
$cat_options[$spec_cat_id]))

    {

        return 
$cat_options[$spec_cat_id];

    }

    if (!isset(
$cat_options[0]))

    {

       
/*

        初始化关键参数:

        $level:当前子节点深度

        $last_cat_id:当前父节点ID

        $options:带有缩进级别的数组

        $cat_id_array:沿同一路径的父节点依次进驻

        $level_array:该节点的子节点深度,也是依次进驻

       */

//这个是后台管理当中的分类列表页

//包含无限分类

include ROOT.'include/tree.class.php';

//声明无限分类

$tree = new tree();

//设置缓存目录

$tree->cDir = ROOT.'cache/class/';

//读入分类缓存

$tree->getCache('class');

//获取缓存

$rootArray = $tree->nodes;      //分类信息在写入缓存之前,就已经按照顺序排列好了,不需再次生成分类树,可以拿来直接进行输出
复制代码//只有在修改数据库中的分类表时才需要重新生成分类树

//包含无限分类

   include ROOT.'include/tree.class.php';

   //声明无限分类

   $tree = new tree();

   //设置缓存目录

   $tree->cDir = ROOT.'cache/class/';

   //查询数据库,返回分类的ID,名称,父类3个字段

   $db->select('all','class','id,name,parent');

   //遍历结果集,并压入无限分类

   while ($row = $db->record('all'))

   {

    $tree->newNode($row['id'],$row['name'],(int)$row['parent']);    //父类ID需要为数字

   }

   //生成分类树,并写入缓存

   $tree->putCache('class');
复制代码//另一种更简便的重写缓存方式,该代码是删除分类页中的

//包含无限分类

include ROOT.'include/tree.class.php';

//声明无限分类

$tree = new tree();

//设置缓存目录

$tree->cDir = ROOT.'cache/class/';

//读入分类缓存

$tree->getCache('class');

//是否存在该分类

if (isset($tree->nodes[$id]))

{

  //生成查询条件

  $condition = 'id='.$id;

  //获取该分类的子分类ID

  $childsId = $tree->getChildsId($id);   //如果存在子分类,改方法返回的是一个一维数组,值分别为各子分类的ID,如果不存在子分类,该方法返回false

  //如果存在子分类

  if ($childsId)

  {

   //如果子分类存在,连同子分类一同删除

   foreach ($childsId as $childId)

   {

    $condition .= ' or id='.$childId;  //生成删除条件

    //卸载无限分类中的条目

    unset($tree->nodes[$childId]);  //直接将分类树中对应ID的分类信息删除

   }

  }

  //开始删除

  $db->delete('class',$condition);

  //删除该分类在无限分类中条目

  unset($tree->nodes[$id]);

  //重写无限分类缓存

  $tree->putCache('class');

 

  //输出删除成功标记

  exit('OK');

} else {

  //不存在则输出错误消息

  exit('该分类不存在!');

}
复制代码

php经典文件上传类
#*********************************************************
#文件名称:
inc_class.upload.php
#功能描述: 上传文件类
#程序制作:青春一度(adleyliu)
#联系qq 
:14339095

2.0.a
#注:转发时请保留此声明信息,这段声明不并会影响你的速度!
#如有修改请将修改后的文件以邮件形式发送给作者一份,谢谢!
#
#*********************************************************
if(!defined('IN_PHPADLEYIU'))
{
 exit('Access Denied');
}

/*
//使用说明:
//声明一个上传类
include_once(ADLEYLIU_ROOT.'./inc_class.upload.php');
$_YL_UPLOAD
= array();
$yl_uploadfile = new
yl_upload_class();
$_YL_UPLOAD['yl_filedata'] =
'uploadFile';//表单名
$_YL_UPLOAD['yl_directroy'] =
'upload_files';//上传主目录
$_YL_UPLOAD['file_urldirectroy'] = '/';//
程序路径
$_YL_UPLOAD['yl_settingsnew'] =
''.date('ym').'/'.date('d').'/'.substr(time(), 0,
5).'';//上传子主目录
$_YL_UPLOAD['yl_maxsize'] = 1048576; 
//这里以字节为单位(1024*2)*1024=2097152 就是 2M
$_YL_UPLOAD['yl_sizeformat'] =
'k';   //显示文件大小单位b字节,k千,m兆
$_YL_UPLOAD['yl_arrext'] =
array('gif','jpg','jpeg','png','bmp','rar','txt');//允许上传文件类型
$_YL_UPLOAD['yl_ext']
= 0;  //0原文件类型上传,1统一为存为jpg
$_YL_UPLOAD['yl_prefix'] =
''.$uid.''.$yl_uploadfile -> yl_createrand(1,0).''.$cid.''; 
//在文件名前缀加上特殊字符 //$uid 会员ID  $cid 分类ID
$_YL_UPLOAD['yl_suffix'] =
'';  //''.$yl_uploadfile -> yl_createrand(3,0).''; 
//在文件名后缀加上特殊字符
$_YL_UPLOAD['thumbwidth'] = 100; 
//缩略图宽
$_YL_UPLOAD['thumbheight'] = 100; 
//缩略图高
$_YL_UPLOAD['maxthumbwidth'] = 500; 
//大图高
$_YL_UPLOAD['maxthumbheight'] = 500; 
//大图宽
//上传
$yl_uploadfile -> yl_uploadfile();
获取值:
'yl_filename'
=> addslashes($_YL_UPLOAD['yl_filename']),原文件名
'yl_attachment' =>
$_YL_UPLOAD['yl_attachment'],新文件名及路径
'yl_filesize' =>
$_YL_UPLOAD['yl_filesize'] ,文件大小
'yl_filetype' =>
$_YL_UPLOAD['yl_filetype'],文件类型
'yl_isimage' =>
$_YL_UPLOAD['yl_isimage'],是否是图片
'yl_isthumb' =>
$_YL_UPLOAD['yl_isthumb'],是否有小图片
*/

class yl_upload_class
{
 function __GET($property_name)
{
  if(isset($this -> $property_name))
{
   return $this -> $property_name;
  } else
{
   return
NULL;
  }
 }
 function __SET($property_name,
$value) {
  $this -> $property_name =
$value;
 }
 
 #*********************************************************
 #生成缩略图
 #*********************************************************

 function makethumb($srcfile) {
  global $_YL_UPLOAD;

  //判断文件是否存在
  if (!file_exists($srcfile))
{
   return '';
  }
  $dstfile =
$srcfile.'.small.jpg';
 
  $bigfile =
$srcfile.'.big.jpg';

  //缩略图大小
  $tow =
intval($_YL_UPLOAD['thumbwidth']);
  $toh =
intval($_YL_UPLOAD['thumbheight']);
  if($tow < 60) $tow =
60;
  if($toh < 60) $toh = 60;

  $make_max = 0;
  $maxtow =
intval($_YL_UPLOAD['maxthumbwidth']);
  $maxtoh =
intval($_YL_UPLOAD['maxthumbheight']);
  if($maxtow >= 300
&& $maxtoh >= 300) {
   $make_max =
1;
  }

  //获取图片信息
  $im = '';
  if($data =
getimagesize($srcfile)) {
   if($data[2] == 1)
{
    $make_max =
0;//gif不处理
    if(function_exists("imagecreatefromgif"))
{
     $im =
imagecreatefromgif($srcfile);
    }
   }
elseif($data[2] == 2)
{
    if(function_exists("imagecreatefromjpeg"))
{
     $im =
imagecreatefromjpeg($srcfile);
    }
   }
elseif($data[2] == 3)
{
    if(function_exists("imagecreatefrompng"))
{
     $im =
imagecreatefrompng($srcfile);
    }
   }
  }
  if(!$im)
return '';

  $srcw = imagesx($im);
  $srch = imagesy($im);

  $towh = $tow/$toh;
  $srcwh =
$srcw/$srch;
  if($towh <= $srcwh){
   $ftow =
$tow;
   $ftoh = $ftow*($srch/$srcw);

   $fmaxtow = $maxtow;
   $fmaxtoh =
$fmaxtow*($srch/$srcw);
  } else {
   $ftoh =
$toh;
   $ftow = $ftoh*($srcw/$srch);

   $fmaxtoh = $maxtoh;
   $fmaxtow =
$fmaxtoh*($srcw/$srch);
  }
  if($srcw <= $maxtow
&& $srch <= $maxtoh) {
   $make_max =
0;//不处理
  }
  if($srcw > $tow || $srch > $toh)
{
   if(function_exists("imagecreatetruecolor") &&
function_exists("imagecopyresampled") && @$ni =
imagecreatetruecolor($ftow, $ftoh))
{
    imagecopyresampled($ni, $im, 0, 0, 0, 0, $ftow,
$ftoh, $srcw,
$srch);
    //大图片
    if($make_max
&& @$maxni = imagecreatetruecolor($fmaxtow, $fmaxtoh))
{
     imagecopyresampled($maxni, $im, 0, 0, 0, 0,
$fmaxtow, $fmaxtoh, $srcw, $srch);
    }else if (@$maxni
= imagecreatetruecolor(round($srcw/2),
round($srch/2))){
     imagecopyresampled($maxni,
$im, 0, 0, 0, 0, round($srcw/2), round($srch/2), $srcw,
$srch);
    }
   }
elseif(function_exists("imagecreate") &&
function_exists("imagecopyresized") && @$ni = imagecreate($ftow, $ftoh))
{
    imagecopyresized($ni, $im, 0, 0, 0, 0, $ftow,
$ftoh, $srcw,
$srch);
    //大图片
    if($make_max
&& @$maxni = imagecreate($fmaxtow, $fmaxtoh))
{
     imagecopyresized($maxni, $im, 0, 0, 0, 0,
$fmaxtow, $fmaxtoh, $srcw, $srch);
    }else if (@$maxni
= imagecreate(round($srcw/2),
round($srch/2))){
     imagecopyresized($maxni, $im,
0, 0, 0, 0, round($srcw/2), round($srch/2), $srcw,
$srch);
    }
   } else
{
    return
'';
   }
   if(function_exists('imagejpeg'))
{
    imagejpeg($ni,
$dstfile);
    //大图片
    if($make_max)
{
     imagejpeg($maxni,
$bigfile);
    }else{
     imagejpeg($maxni,
$bigfile);
    }
   }
elseif(function_exists('imagepng')) {
    imagepng($ni,
$dstfile);
    //大图片
    if($make_max)
{
     imagepng($maxni,
$bigfile);
    }else{
     imagejpeg($maxni,
$bigfile);
    }
   }
   imagedestroy($ni);
   if($make_max)
{
   }else{
    imagedestroy($maxni);
   }
  }else{


          
if(function_exists("imagecreatetruecolor") &&
function_exists("imagecopyresampled") && @$ni =
imagecreatetruecolor($srcw, $srch))
{
    imagecopyresampled($ni, $im, 0, 0, 0, 0, $srcw,
$ftoh, $srch,
$srch);
    //大图片
     $maxni =
imagecreatetruecolor($srch, $srch);
    
imagecopyresampled($maxni, $im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
 
   } elseif(function_exists("imagecreate")
&& function_exists("imagecopyresized") && @$ni =
imagecreate($ftow, $ftoh)) {
    imagecopyresized($ni,
$im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
    //大图片
     $maxni =
imagecreate($fmaxtow, $fmaxtoh);
    
imagecopyresized($maxni, $im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
   
   } else
{
    return
'';
   }
                
imagejpeg($ni, $dstfile);

     imagejpeg($maxni,
$bigfile);
 
  }

  imagedestroy($im);

  if(!file_exists($dstfile)) {
   return
'';
  } else {
   return
$dstfile;
  }
 }

 #*********************************************************
 #获取随机数函数
 #*********************************************************
 function
yl_createrand($length, $numeric = 0) {
  PHP_VERSION < '4.2.0'
&& mt_srand((double)microtime() * 1000000);
  if($numeric)
{
   $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10,
$length) - 1));
  } else {
   $hash =
'';
   $chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';///0123456789
   $max
= strlen($chars) - 1;
   for($i = 0; $i < $length; $i++)
{
    $hash .= $chars[mt_rand(0,
$max)];
   }
  }
  return
$hash;
 }
 #***************
 #*********************************************************
 #创建目录函数
 #*********************************************************
 function
createfolder($yl_path)
 {
  if
(!file_exists($yl_path))
  {
   $this ->
createfolder(dirname($yl_path));
   @mkdir($yl_path,
0777);
  }
  return $this ->
createfolder;
 }
 #*********************************************************
 #获取文件
名称,大小,类型,临时文件名
 #*********************************************************
 function
yl_getfilename($yl_type)
 {
  global
$_YL_UPLOAD;
  return
$_FILES[$_YL_UPLOAD['yl_filedata']][$yl_type];
 }
 #*********************************************************
 #获取文件大小
 #*********************************************************
 function
yl_getfilesize()
 {
  global
$_YL_UPLOAD;
  $yl_filesize = $this ->
yl_getfilename('size');
  if($yl_filesize ==
0){
   $this ->
alert("请选择上传文件!");
   exit;
  }
  if($yl_filesize
> $_YL_UPLOAD['yl_maxsize']){

   switch
(strtolower($_YL_UPLOAD['yl_sizeformat'])){
    case
'b':
     $yl_maxsizek = $_YL_UPLOAD['yl_maxsize'] .
' B';
     break;
    case
'k':
     $yl_maxsizek =
$_YL_UPLOAD['yl_maxsize']/1024 . '
K';
     break;
    case
'm':
     $yl_maxsizek =
$_YL_UPLOAD['yl_maxsize']/(1024*1024) . '
M';
   }
   $this ->
alert("上传文件超出限制范围[".$yl_maxsizek."].K!");
   exit;
  }
  return
$yl_filesize;
 }
 #*********************************************************
 #获得文件扩展名
 #*********************************************************
 function
yl_getfiletype()
 {
  global
$_YL_UPLOAD;
  $pathinfo = pathinfo($this ->
yl_getfilename('name'));
  $yl_file_ext =
strtolower($pathinfo['extension']);
  //检查扩展名
  if(!array_keys($_YL_UPLOAD['yl_arrext'],$yl_file_ext))
{
   $this ->
alert("上传文件类型被限制!");
   exit;
  }
  return
$yl_file_ext;
 }

 #*********************************************************
 #上传验证
 #*********************************************************
 function
yl_upfile($source, $target) {
  //
如果一种函数上传失败,还可以用其他函数上传
  if (function_exists('move_uploaded_file')
&& @move_uploaded_file($source, $target))
{
   @chmod($target, 0666);
   return
$target;
  } elseif (@copy($source, $target))
{
   @chmod($target, 0666);
   return
$target;
  } elseif (@is_readable($source))
{
   if ($fp = @fopen($source,'rb'))
{
    @flock($fp,2);
    $filedata
=
@fread($fp,@filesize($source));
    @fclose($fp);
   }
   if
($fp = @fopen($target, 'wb')) {
    @flock($fp,
2);
    @fwrite($fp,
$filedata);
    @fclose($fp);
    @chmod
($target, 0666);
    return
$target;
   } else {
    return
false;
   }
  }
 }
 #*********************************************************
 #上传
 #*********************************************************
 function
yl_uploadfile()
 {
  global
$_YL_UPLOAD;
  $yl_file_path =
$_YL_UPLOAD['yl_directroy'].'/'.$_YL_UPLOAD['yl_settingsnew']
;//建立一个目录
  $yl_filename = $this ->
yl_getfilename('name');//原文件名
  $yl_filenamenews =
$_YL_UPLOAD['yl_prefix'].''.substr(time(), 5,
9).''.$_YL_UPLOAD['yl_suffix'].'';//重命名
  $yl_file_size = $this
-> yl_getfilesize();//获取文件大小
  $yl_file_type = $this ->
yl_getfiletype();//获取文件类型
  if($_YL_UPLOAD['yl_ext'] ==
0){
   $yl_filenamenewsext =
$yl_filenamenews.'.'.$yl_file_type;//改名
  }elseif
($_YL_UPLOAD['yl_ext'] == 1){
   $yl_filenamenewsext =
$yl_filenamenews.'.jpg';//统一改名为jpg
  }
  //$yl_tmp_name
=  str_replace(' ','',$this ->
yl_getfilename('tmp_name'));//服务器上临时文件名
  $yl_tmp_name = 
$this ->
yl_getfilename('tmp_name');//服务器上临时文件名
  //检查是否已上传
  if(<A
href="mailto:!@is_uploaded_file($yl_tmp_name">!@is_uploaded_file

($yl_tmp_name))
{
   $this ->
alert("文件已上传!");
   exit;
  }
  //检查目录是否存在,不存在则创建
  if(<A
href="mailto:!@is_dir(''.$_YL_UPLOAD

['file_urldirectroy'].''.$yl_file_path.''">!@is_dir(''.$_YL_UPLOAD

['file_urldirectroy'].''.$yl_file_path.''))
{
   $this ->
createfolder(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.'');//创建

目录
  }
  //检查目录写权限
  if
(<A
href="mailto:!@is_writable(''.$_YL_UPLOAD

['file_urldirectroy'].''.$yl_file_path.''">!@is_writable(''.$_YL_UPLOAD

['file_urldirectroy'].''.$yl_file_path.''))
{
   $this ->
alert("上传目录没有写权限!");
   exit;
  }
  $yl_path_name
=
''.$_YL_UPLOAD

['file_urldirectroy'].''.$yl_file_path.'/'.$yl_filenamenewsext.'';
  $yl_doupload
= $this -> yl_upfile($yl_tmp_name, $yl_path_name);

  if($yl_doUpload ===
false)
  {
   $this ->
alert("上传失败!");
   exit;
  }else{
   //echo
'上传成功';
   //echo
'<br>';
   /*
   echo
'原文件名:'.$yl_filename.'';
   echo
'<br>';
   echo
'新文件名及目录:'.$yl_file_path.'/'.$yl_filenamenewsext;
   echo
'<br>';
   echo
'文件大小:'.$yl_file_size.'';
   echo
'<br>';
   echo
'文件类型:'.$yl_file_type.'';
   */
   $_YL_UPLOAD['yl_filename']
= $yl_filename;
   $_YL_UPLOAD['yl_attachment'] =
''.$yl_file_path.'/'.$yl_filenamenewsext.'';
   $_YL_UPLOAD['yl_filesize']
= $yl_file_size;
   $_YL_UPLOAD['yl_filetype'] =
$yl_file_type;
   //检查是否图片
   if(@getimagesize($yl_path_name))
{
    $_YL_UPLOAD['yl_isimage'] =
1;
    ///生成缩略图
    if ($this
->
makethumb($yl_path_name)){
     $_YL_UPLOAD['yl_isthumb']
=
1;
    }else{
     $_YL_UPLOAD['yl_isthumb']
=
0;
    }
   }else{
    $_YL_UPLOAD['yl_isimage']
= 0;
   }
  }
  return
true;
 }

 #*********************************************************
 #提示
 #*********************************************************
 function
alert($yl_msg)
 {
  echo
'<html>';
  echo '<head>';
  echo
'<title>error</title>';
  echo '<meta
http-equiv="content-type" content="text/html;
charset=gb2312">';
  echo '</head>';
  echo
'<body>';
  echo '<script
type="text/javascript">alert("'.$yl_msg.'");history.back();</script>';
  echo
'</body>';
  echo
'</html>';
  exit;
 }
}

PHP常用缓存方式入门教程
第一种,把需要缓存的数据进行处理,形成PHP可以直接执行的文件。在需要缓存数据

的时候,通过include方式引入,并使用。
第二种,把需要的数据通过serialize函数序列化后直接保存到文件。在需要使用缓存

数据的时候,通过反序列化读入文件内容并复制给需要的变量,然后使用。

测试结果:
通过测试我们发现,第二种也就是serialize缓存数据的方式更加高效。(数据略去,

最后提供了文章地址下载,大家可以自行测试)

原因分析:
include方式读取缓存的时候,PHP需要执行几个过程
1.读取文件
2.解析所Include的文件
3.执行,给变量赋值

而serialize序列化方式读取缓存的时候:
1.读取数据
2.反序列化数据内容
3.给变量赋值

从以上内容对比的话,可能是由于解析PHP文件内的数组需要的时间超过unserialize反

序列化数组的时间。如果你有兴趣可以查看《PHP filesystem相关函数和include

require的性能效率研究》:http://www.ccvita.com/163.html

测试文件代码:
下载地址:MooPHP-CacheTest.zip
原创地址:http://www.ccvita.com/311.html 有新的研究心得会在这里更新。
CacheTest_IncludeFile.php
CacheTest_SerializeFile.php

总结分析:
第一种,include缓存的方式
优点:增加数据的保密性,和安全性,缓存内容不会被外界发现。
缺点:速度相对较慢。
用途:保存禁止系统外部得知的数据,比如web系统的设置,甚至MySQL信息等的保存
第二种,serialize序列化缓存的方式
优点:速度较快。
缺点:缓存系统文件路径一点曝光,缓存内容会泄露。
用途:缓存最新文章,相关文章等不担心外部得知的数据的时候,可以使用这种方式。

备注:
当装了ea、apc等PHP内存缓存之后,第一种通过include读取缓存的方式速度会高于第

二种serialize序列化缓存的方式。所以在MooPHP框架中,我们对于非敏感信息采用第

二种方式缓存;敏感信息采用第一种方式缓存

[!--infotagslink--]

相关文章

  • 使用PHP+JavaScript将HTML页面转换为图片的实例分享

    这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19
  • C#从数据库读取图片并保存的两种方法

    这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
  • Photoshop古装美女图片转为工笔画效果制作教程

    今天小编在这里就来给各位Photoshop的这一款软件的使用者们来说说把古装美女图片转为细腻的工笔画效果的制作教程,各位想知道方法的使用者们,那么下面就快来跟着小编一...2016-09-14
  • Python 图片转数组,二进制互转操作

    这篇文章主要介绍了Python 图片转数组,二进制互转操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-09
  • php抓取网站图片并保存的实现方法

    php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...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
  • jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮

    jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮...2013-10-13
  • 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
  • 利用JS实现点击按钮后图片自动切换的简单方法

    下面小编就为大家带来一篇利用JS实现点击按钮后图片自动切换的简单方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-10-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实现上传图片及时预览的相关资料,具有一定的参考价值,感兴趣的朋友可以参考一下...2016-05-09
  • js识别uc浏览器的代码

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

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • Photoshop枪战电影海报图片制作教程

    Photoshop的这一款软件小编相信很多的人都已经是使用过了吧,那么今天小编在这里就给大家带来了用Photoshop软件制作枪战电影海报的教程,想知道制作步骤的玩家们,那么下面...2016-09-14
  • 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