1 Star 0 Fork 0

岳小威子 / space

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
function.php 867 Bytes
一键复制 编辑 原始数据 按行查看 历史
alan.yue 提交于 2021-03-21 13:33 . test
<?php
function get_http_type(){
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
return $http_type;
}
function size_unit($num){
$p = 0;
$format='Byte';
if($num>0 && $num<1024){
$p = 0;
return number_format($num).' '.$format;
}
if($num>=1024 && $num<pow(1024, 2)){
$p = 1;
$format = 'KB';
}
if ($num>=pow(1024, 2) && $num<pow(1024, 3)) {
$p = 2;
$format = 'MB';
}
if ($num>=pow(1024, 3) && $num<pow(1024, 4)) {
$p = 3;
$format = 'GB';
}
if ($num>=pow(1024, 4) && $num<pow(1024, 5)) {
$p = 3;
$format = 'TB';
}
$num /= pow(1024, $p);
return number_format($num, 3).' '.$format;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/alan-yuewei/space.git
git@gitee.com:alan-yuewei/space.git
alan-yuewei
space
space
master

搜索帮助