<? class encryptCalss { var $key=12; function encode($txt){ for($i=0;$i<strlen($txt);$i++){ $txt[$i]=chr(ord($txt[$i])+$this->key); } return $txt=urlencode(base64_encode(urlencode($txt))); } function
一段php生成随机颜色的代码,如:FF00FF function random_color(){ mt_srand((double)microtime()*1000000); $c = ''; while(strlen($c)<6){
php /** * “抽奖”函数 * * @param integer $first 起始编号 * @param integer $last 结束编号 * @param integer $total
function create_dir($path,$mode) { if (is_dir($path)){ //判断目录存在否,存在不创建 echo "目录'" . $path . "'已经存在"; } else { //不存在创建 $re=mkdir($path,$mode,true); //第三个参数为true即可以创建多极目录 if ($re){ echo "目录创建成功"; }else{
php $str="0123456789abcdefghijklmnopqrstuvwxyz"; $tmp=$str[mt_rand(0,35)].$str[mt_rand(0,35)].$str[mt_rand(0
<pre name="code" class="html"><? $int=36; $str=array(); $flag=0; //echo chr($int%36+87); while($int!=0) { if($int%36<=9)$str[$flag++]=$int%36;//36进制 else $str[$flag++]=chr($int%36+87); $int/=36; } for
一共有3个文件: 1、functions.php 2、water.config.php 3、water.class.php 代码如下: functions.php php /* * */ //获得数据库模型的对象
php获取图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息 php echo "test1.jpg:
\n"; $exif = exif_
php session_start(); // main $vcodes = ''; //generate Number 4 srand((double) microtime() * 1000000);
PHP 文件上传代码示例
可。不知道能程序的性能会不会影响很大! ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行. set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去
/** * Downloader * * @param $archivo * path al archivo * @param $downloadfilename * (null|string) el nombre que queres usar para el archivo que se va a descargar. * (si no lo especificas usa el nombre
<? function Text2Html($txt){ $txt = str_replace(" "," ",$txt); $txt = str_replace("<","<",$txt); $txt = str_replace(">",">",$txt); $txt = preg_replace("/[rn]{1,}/isU"," rn",$txt); return $txt; }
//把全角数字转为半角数字 <? function GetAlabNum($fnum){ $nums = array("0","1","2","3","4","5","6","7","8","9"); //OSPHP.com.CN $fnums = "0123456789"; for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i]
php /** * 常用静态类,这里主要整理了一些PHP常常会用到的方法。 */ class C { /* * 私有处理随机数的内置参数 * array 随机数数组/param 随机数长度 * 返回一个随机数
function pdf2png($PDF,$Path){ if(!extension_loaded('imagick')){ return false; } if(!file_exists($PDF)){ return false; } $IM = new imagick(); $IM->setResolution(120,120); $IM->setCompressionQuality(100
// $low and $high have to be integers function BinarySearch( $array, $key, $low, $high ) { if( $low > $high ) // termination case { return -1; } $middle = intval( ( $low+$high )/2 ); // gets the middl
对指定的关键词进行替换处理,在html页面上高亮显示 function highlight($sString, $aWords) { if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) { return false; } $sWords = implode ('|', $aWords); return preg_
php $date1 = date( 'Y-m-d' ); $date2 = "2015-12-04"; $diff = abs(strtotime($date2) - strtotime($date1));
php // local file that should be send to the client $local_file = 'test-file.zip'; // filename that