PHP中获取文件扩展名的N种方法 从网上收罗的,基本上就以下这几种方式: 第1种方法: function get_extension($file){substr(strrchr($file, .), 1);} 第2种方法: function get_extension($file){return substr($file, strrpos($file, .)+1);} 第3种方法:
纯数字的四位随机数rand(1000,9999)数字和字符混搭的四位随机字符串:function GetRandStr($len) { $chars = array( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R
?php//取出首字母函数function getfirstchar($s0){ if(ord($s0)=1 and ord($s0)=ord(z) ) { return strtoupper($s0); } //$s=iconv(UTF-8,gb2312, $s0); 如果需要转换为utf-8的话$s=$s0;//无需转换的情况$asc=ord($s{0})*256+ord($s{1})-65536; if($asc=-203