// local file that should be send to the client $local_file = 'test-file.zip'; // filename that the user gets as default $download_file = 'your-download-name.zip'; // set the download rate limit (=> 2
对指定的关键词进行替换处理,在html页面上高亮显示 function highlight($sString, $aWords) { if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) { return false; } $sWords = implode ('|', $aWords); return preg_
/********************** *@file - path to zip file *@destination - destination directory for unzipped files */ function unzip_file($file, $destination){ // create object $zip = new ZipArchive() ; // op
function qsort(&$arr) { _quick_sort($arr, 0, count($arr) - 1); } /** * 采用递归算法的快速排序。 * * @param array $arr 要排序的数组 * @param int $low 最低的排序子段 * @param int $high 最高的排序字段 */ function _quick_sort(&$arr, $lo
<?phpclass CtbClass { var $file; var $index; //建立一个文件并写入输入 function null_write($new) { $f=fopen($this->file,"w"); flock($f,LOCK_EX); fputs($f,$new); fclose($f); } // 添加数据记录到文件末端 function add_write($ne
//非递归获取所有后代分类 function get_offspring($pids, $list) { $npid = array(); $offspring = array(); $has_child = true; while($has_child) { $has_child = false; foreach($list as $lk => $lv) { if(in_array($lv['p
set_time_limit(0); // Supports all file types // URL Here: $url = 'http://somsite.com/some_video.flv'; $pi = pathinfo($url); $ext = $pi['extension']; $name = $pi['filename']; // create a new cURL reso
class User { static function getInstance() { if (self::$instance == NULL) { // If instance is not created yet, will create it. self::$instance = new User(); } return self::$instance; } private functio
/** * 图片缩放水印类 * */ class cls_photo { protected $waterrate = 0.2; //水印图标在图片上的比例 protected $width = 300; //缩略图默认宽度 protected $height = 200; //缩略图默认高度 protected $padding = 5; //水印图到边的距离 protected $water_
$arr = array(3,5,-1,0,2); for($i=0;$i<count($arr)-1;$i++){ for($j=0;$j<count($arr)-1-$i;$j++){ if($arr[$j]>$arr[$j+1]){ $temp = $arr[$j]; $arr[$j]=$arr[$j+1]; $arr[$j+1]=$temp; } } }
// local file that should be send to the client $local_file = 'test-file.zip'; // filename that the user gets as default $download_file = 'your-download-name.zip'; // set the download rate limit (=> 2
if (isset($_GET['dir'])){ //设置文件目录 $basedir=$_GET['dir']; }else{ $basedir = '.'; } $auto = 1; checkdir($basedir); function checkdir($basedir){ if ($dh = opendir($basedir)) { while (($file = readdir($d
$i = imagecreatefromjpeg("image.jpg"); for ($x=0;$x<imagesx($i);$x++) { for ($y=0;$y<imagesy($i);$y++) { $rgb = imagecolorat($i,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF
/** * 禁词过滤 * 执行效率:每篇用时0.05秒 * @author liuxu * */ class Logic_BlackWord { const APP_FORUM = 1; const APP_BLOG = 2; const APP_VOTE = 3; /** * 过滤得到禁词 * @param unknown $txt * @return Ambigous <multitype:,
php class FileUpload{ private $filepath; //设置上传文件的路径 private $allowtype=array('jpg','jpeg','gif','bmp');
PHP 下载远程文件类,支持断点续传下载,代码内含有具体的调用说明。程序主要是使用 HTTP 协议下载文件,HTTP1.1协议必须指定文档结束后关闭链接,否则读取文档时无法使用feof判断结束,可以有两种使用方法,具体请下载查看源码。
php $data='username=zjzhoufy@126.com&password=1q2w3e&remember=1'; $curlobj = curl_init(); // 初始化 curl_setopt($curlobj
php $url = 'sales@example.com'; echo ltrim(strstr($url, '@'),'@'); ?>
php $old = 'C:\tmp\someold.txt'; $new = 'C:\tmp\somenew.txt'; copy($old,$new) or die("couldn't copy
microtime():获取毫秒级的UNIX时间戳 php $t=microtime(); /* 你要执行的代码 */ echo "哦啦啦啦啦啦啦啦"; $t=microtime()-$t; echo