php $conn = new Mongo(); //可以简写为 //$conn=new Mongo(); #连接本地主机,默认端口. //$conn=new Mongo(“172.21.15.69″);
php /* * 中文圆形印章类 * @author lkk/lianq.net * @create on 10:03 2012-5-29 * @example: * $seal = new ci
php /** * 验证类 * * @lastmodify 2014-5-16 * @author jy625 */ class VerifyAction{ /** * 是否为空值 */ public
php /** * 获得文件的mime type类型 * @author xiaobing.meng * */ class MimeTypes { public static $mime_types
array_merge($left_array, array($base_num), $right_array); } 来源: php100
php /* * Author 墨龙 * Time 2010年12月2日 15:50:35 */ $db = new mysql($db_host,$db_user,$db_password,$db_table
php class Fun{ function isEmpty($val) { if (!is_string($val)) return false; //是否是字符串类型 if (empty($val))
php /********************************* * Code by Gently * 24/07/07 *严正声明:验证码为程序随机生成,“某种巧合”的词语组合属于正常现象
名方式可以考虑在原图片的基础上加上步骤,例如:图片名称+__第几步。 在一些需要图片高级处理功能的Web应用中,可以参考这个类。 php /* 图片处理函数功能:缩放、剪切、相框、水印、锐化、旋转、翻转、透明度、反色 处理并保存历史记
php /** * Class Lunar * 农历 节气 节日 * author:guoyu@xzd */ class Lunar { public $MIN_YEAR = 1891; public
function randomColor() { $str = '#'; for($i = 0 ; $i < 6 ; $i++) { $randNum = rand(0 , 15); switch ($randNum) { case 10: $randNum = 'A'; break; case 11: $randNum = 'B'; break; case 12: $randNum = 'C';
$arr=array(2,1,-1,3,0); for($i=1;$i<count($arr);$i++){ $insertval=$arr[$i]; $insertindex = $i-1; while($insertindex>=0 && $insertval<$arr[$insertindex]){ $arr[$insertindex+1]=$arr[$insertindex]; $inse
// 备份数据库 $host = "localhost"; $user = "root"; //数据库账号 $password = ""; //数据库密码 $dbname = "mysql"; //数据库名称 // 这里的账号、密码、名称都是从页面传过来的 if (!mysql_connect($host, $user, $password)) // 连接mysql数据库 { echo '数据库连
$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
function download_file($file){ if(is_file($file)){ $length = filesize($file); $type = mime_content_type($file); $showname = ltrim(strrchr($file,'/'),'/'); header("Content-Description: File Transfer");
<? 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
function auth_pwgen(){ $pw = ''; $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones $v = 'aeiou'; //vowels $a = $c.$v; //both //use two syllables... for($i=0;$i < 2; $i++){ $pw .= $c[ra
我们先来分析下规律。 设定总金额为10元,有N个人随机领取: N=1 第一个 则红包金额=X元; N=2 第二个 为保证第二个红包可以正常发出,第一个红包金额=0.01至9.99之间的某个随机数。 第二个红包=10-第一个红包金额; N=3 第三个 红包1=0.01至9.99之间的某个随机数 红包2=0.01至(10-红包1-0.01)的某个随机数 红包3=10-红包1-红包2 …… 于是我们得到
1. 冒泡排序 思路分析:在要排序的一组数中,对当前还未排好的序列,从前往后对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒。即,每当两相邻的数比较后发现它们的排序与排序要求相反时,就将它们互换。 代码实现: $arr=array(1,43,54,62,21,66,32,78,36,76,39); function bubbleSort($arr) { $len=count($ar
$f = file('words.txt'); $words = array(); foreach ($f as $w) { $words[] = preg_quote(trim($w), '/'); } $text = file_get_contents('text.txt'); $start = microtime(true); $reg = '/' . implode('|', $words