闲者博客 - 获取 https://bk1314.com/tag/%E8%8E%B7%E5%8F%96/ zh-CN Fri, 25 Feb 2022 18:51:51 +0800 Fri, 25 Feb 2022 18:51:51 +0800 PHP获取当前页面URL https://bk1314.com/39.html https://bk1314.com/39.html Fri, 25 Feb 2022 18:51:51 +0800 飞鱼 function curPageURL() { $pageURL = 'http'; if (!empty($_SERVER['HTTPS'])) {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } echo curPageURL(); ]]> 0 https://bk1314.com/39.html#comments https://bk1314.com/feed/tag/%E8%8E%B7%E5%8F%96/ PHP获取文件扩展名(后缀) https://bk1314.com/37.html https://bk1314.com/37.html Fri, 25 Feb 2022 18:49:56 +0800 飞鱼 function getExtension($filename){ $myext = substr($filename, strrpos($filename, '.')); return str_replace('.','',$myext); } $filename = '我的文档.doc'; echo getExtension($filename); ]]> 0 https://bk1314.com/37.html#comments https://bk1314.com/feed/tag/%E8%8E%B7%E5%8F%96/ PHP获取文件大小并格式化 https://bk1314.com/36.html https://bk1314.com/36.html Fri, 25 Feb 2022 18:48:25 +0800 飞鱼 function formatSize($size) { $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); if ($size == 0) { return('n/a'); } else { return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); } } $thefile = filesize('test_file.mp3'); echo formatSize($thefile); ]]> 0 https://bk1314.com/36.html#comments https://bk1314.com/feed/tag/%E8%8E%B7%E5%8F%96/