基本函数

/**
* 检查邮箱是否有效
* @param $email 要检查的邮箱
* @param 返回结果
*/
function isemail($email) {
        return strlen($email) > 6 && preg_match("/^[\w\-\.][email protected][\w\-\.]+(\.\w+)+$/", $email);
}

/**
* 产生随机码
* @param $length - 要多长
* @param $numberic - 数字还是字符串
* @return 返回字符串
*/
function random($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 = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz‘;
                $max = strlen($chars) - 1;
                for($i = 0; $i < $length; $i++) {
                        $hash .= $chars[mt_rand(0, $max)];
                }
        }
        return $hash;
}

/**
* 删除非空目录
* @param $path 目录
*/
function removedir($dirname, $keepdir = FALSE) {

$dirname = wipespecial($dirname);

if(!is_dir($dirname)) {
                return FALSE;
        }
        $handle = opendir($dirname);
        while(($file = readdir($handle)) !== FALSE) {
                if($file != ‘.‘ && $file != ‘..‘) {
                        $dir = $dirname . DIRECTORY_SEPARATOR . $file;
                        is_dir($dir) ? removedir($dir) : unlink($dir);
                }
        }
        closedir($handle);
        return !$keepdir ? (@rmdir($dirname) ? TRUE : FALSE) : TRUE;
}

时间: 2024-08-25 12:42:24

基本函数的相关文章

MySQL数据库(7)_用户操作与权限管理、视图、存储过程、触发器、基本函数

用户操作与权限管理 MySQL用户操作 创建用户 方法一: CREATE USER语句创建 CREATE USER "用户名"@"IP地址" IDENTIFIED BY "密码"; 方法二: INSERT语句创建 INSERT INTO mysql.user(user,host, password,ssl_cipher,x509_issuer,x509_subject) VALUES('用户名','IP地址',password('密码'),'',

文华财经基本函数及语法

文华财经基本函数及语法 (2015-11-15 12:07:37) 转载▼   分类: Finance   编辑平台支持的操作符 操作符 意义 例 + 加法 CLOSE+OPEN 表示求收盘价及开盘价的和.CLOSE-OPEN 表示求收盘价及开盘价的差.CLOSE*OPEN 表示求收盘价及开盘价的积.CLOSE/OPEN 表示求收盘价及开盘价的商. - 减法 * 乘法 / 除法 && 与(并且) CLOSE>OPEN 表示判断当前周期是否收阳.CLOSE=OPEN 表示判断当前周期是

java大数的基本函数

1.读入 Scanner cin=new Scanner(System.in);// 读入 while(cin.hasNextInt()) //等同于!=EOF,第一数一定要输入整形的 { } 大数的一般是: while(cin.hasNextBigInteger())  //第一个数一定要输入大数的 { } while(t-->0)   //等同于while(t--) { } 2.赋值 BigInteger b=BigInteger.valueOf(a); //a可为int,long,stri

python常用基本函数

python常用基本函数,布布扣,bubuko.com

MySQL存储过程的基本函数(三)

(1).字符串类 首先定义一个字符串变量:set @str="lxl";CHARSET(str) //返回字串字符集 select charset(@str);+---------------+| charset(@str) |+---------------+| utf8          |+---------------+ CONCAT (string [,... ]) //连接字串 select concat(@str,"hello");+---------

Lua中的基本函数库

基本函数库为Lua内置的函数库,不需要额外装载 assert (v [, message])功能:相当于C的断言,参数:v:当表达式v为nil或false将触发错误,message:发生错误时返回的信息,默认为"assertion failed!" -------------------------------------------------------------------------------- collectgarbage (opt [, arg])功能:是垃圾收集器的通

Matlab基本函数-conj函数

Matlab基本函数-conj函数 1.conj函数:用于计算复数的共轭值 2.用法说明:y=conj(x)函数计算复数x的共轭值.输出结果y的维数跟输入x的维数一致,返回值为:real(y)-i*imag(y) 3.实例 >> x = [3+4i 5-6i 7+10i 23+12i]x =   3.0000 + 4.0000i   5.0000 - 6.0000i   7.0000 +10.0000i  23.0000 +12.0000i >> y = conj(x)y =  3

SQL Server基本函数

SQL Server基本函数 SQL Server基本函数 1.字符串函数 长度与分析用 1,datalength(Char_expr) 返回字符串包含字符数,但不包含后面的空格2,substring(expression,start,length) 取子串,字符串的下标是从"1",start为起始位置,length为字符串长度,实际应用中以len(expression)取得其长度3,right(char_expr,int_expr) 返回字符串右边第int_expr个字符,还用lef

mysql 基本函数

MySQL中有很多有用的函数,而基本的函数可以分为字符串函数,日期和时间函数,数学函数,系统函数.下面是这些基本函数的例子. 一.字符串函数 -- mysql字符串函数 -- select instr('I am a student.','student'); -- 返回一个指定的字符串在另一个字符串的起始位置 ---- 8 select length('mysql'); -- 返回字符串长度 ---- 5 select lower('MySQL'); -- 把字符串的大写字母转化为小写字母 -

Complex 类的基本函数

//  Complex 类的基本函数 #include<iostream> using namespace std; class Complex { public : Complex(double real=1.0,double image=2.0)//构造函数  (有参) 调用2次拷贝构造 { _real=real; _image=image; } Complex()  //构造函数  (无参) {       _real=1.0;       _image=2.0; } 亦可写成: Com