• 常用功能函数


    // 随机字符串
    function random($length, $numeric = FALSE) {
        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
        if ($numeric) {
            $hash = '';
        } else {
            $hash = chr(rand(1, 26) + rand(0, 1) * 32 + 64);
            $length--;
        }
        $max = strlen($seed) - 1;
        for ($i = 0; $i < $length; $i++) {
            $hash .= $seed{mt_rand(0, $max)};
        }
        return $hash;
    }
    
    // 单位转化
    function sizecount($size) {
        if($size >= 1073741824) {
            $size = round($size / 1073741824 * 100) / 100 . ' GB';
        } elseif($size >= 1048576) {
            $size = round($size / 1048576 * 100) / 100 . ' MB';
        } elseif($size >= 1024) {
            $size = round($size / 1024 * 100) / 100 . ' KB';
        } else {
            $size = $size . ' Bytes';
        }
        return $size;
    }
  • 相关阅读:
    CSS中z-index的层级树概念
    随记
    PHP 随笔
    linux 相关
    Nginx 虚拟主机 VirtualHost 配置
    PHP 杂记
    Composer 资料
    PHP Yii架构学习
    java 日志技术汇总(log4j , Commons-logging,.....)
    Java 随笔
  • 原文地址:https://www.cnblogs.com/ahwu/p/5484391.html
Copyright © 2020-2023  润新知