php用静态类实现获取客户端IP地址的方法
时间:2021-07-01 10:21:17
帮助过:3人阅读
/** - * Miscellaneous utility methods.
- */
- final class Utils {
private function __construct() { -
- }
/** - * Get IP address
- * @return string IP address string
- */
- public static function getIpAddress() {
- return $_SERVER["REMOTE_ADDR"];
- }
- }
- ?>
2、调用
- $last_login_ip = Utils::getIpAddress();
- ?>
|