MongoDB数据库常用操作PHP代码 代码段

php $conn = new Mongo(); //可以简写为 //$conn=new Mongo(); #连接本地主机,默认端口. //$conn=new Mongo(“172.21.15.69″);

pw36 2015-02-07   7654   0
PHP   MongoDB  

实现中文圆形印章的PHP 代码段

php /* * 中文圆形印章类 * @author lkk/lianq.net * @create on 10:03 2012-5-29 * @example: * $seal = new ci

phpde 2015-03-17   975   0
PHP  

一个很好的PHP验证类 代码段

php /** * 验证类 * * @lastmodify 2014-5-16 * @author jy625 */ class VerifyAction{ /** * 是否为空值 */ public

mmxn 2015-05-20   1163   0
PHP  

PHP获得文件的mime type类型 代码段

php /** * 获得文件的mime type类型 * @author xiaobing.meng * */ class MimeTypes { public static $mime_types

程序猿123 2015-03-11   1236   0
PHP  

PHP 四种基本排序算法的代码实现 代码段

array_merge($left_array, array($base_num), $right_array); } 来源: php100

jopen 2015-03-17   2545   1
PHP  

一个数据库操作PHP 代码段

php /* * Author 墨龙 * Time 2010年12月2日 15:50:35 */ $db = new mysql($db_host,$db_user,$db_password,$db_table

wdfd 2015-03-27   1686   0
PHP  

php检测输入数据是否合法常用的类 代码段

php class Fun{ function isEmpty($val) { if (!is_string($val)) return false; //是否是字符串类型 if (empty($val))

n672 2015-02-07   8512   0
PHP  

生成中文验证码的PHP代码 代码段

php /********************************* * Code by Gently * 24/07/07 *严正声明:验证码为程序随机生成,“某种巧合”的词语组合属于正常现象

6e72 2015-01-22   4760   0
PHP  

一个多功能的php图片处理类 代码段

名方式可以考虑在原图片的基础上加上步骤,例如:图片名称+__第几步。 在一些需要图片高级处理功能的Web应用中,可以参考这个类。 php /* 图片处理函数功能:缩放、剪切、相框、水印、锐化、旋转、翻转、透明度、反色 处理并保存历史记

xm52 2015-05-08   1136   0
PHP  

php将阳历转换为阴历 代码段

php /** * Class Lunar * 农历 节气 节日 * author:guoyu@xzd */ class Lunar { public $MIN_YEAR = 1891; public

n5em 2015-06-05   819   0
PHP  

PHP随机颜色生成器 代码段

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';

md3c 2015-01-04   1068   0
PHP  

php插入排序例子 代码段

$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

wp5x 2015-01-10   804   0
PHP  

php数据库备份脚本 代码段

// 备份数据库 $host = "localhost"; $user = "root"; //数据库账号 $password = ""; //数据库密码 $dbname = "mysql"; //数据库名称 // 这里的账号、密码、名称都是从页面传过来的 if (!mysql_connect($host, $user, $password)) // 连接mysql数据库 { echo '数据库连

php7228 2015-01-13   3823   0
PHP  

PHP检测图片的主要颜色 代码段

$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

ded3b 2015-01-23   1019   0
PHP  

PHP实现简单的文件下载通用方法 代码段

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");

lpki124 2015-03-03   1821   0
PHP  

php实现base64的编码和解码 代码段

<? 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

n7w77 2015-03-19   915   0
PHP  

php随机密码生成器 代码段

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

jphp 2015-05-11   924   0
PHP  

PHP实现发红包程序 代码段

我们先来分析下规律。 设定总金额为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 …… 于是我们得到

jopen 2015-07-10   3006   0
PHP  

PHP四大基本排序算法实例 代码段

1. 冒泡排序 思路分析:在要排序的一组数中,对当前还未排好的序列,从前往后对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒。即,每当两相邻的数比较后发现它们的排序与排序要求相反时,就将它们互换。 代码实现: $arr=array(1,43,54,62,21,66,32,78,36,76,39); function bubbleSort($arr) { $len=count($ar

jopen 2015-08-24   878   0

PHP敏感字过滤代码 代码段

$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

jopen 2015-08-29   973   0
PHP  
1 2 3 4 5 6 7 8 9 10