Home > Backend Development > PHP Tutorial > PHP uses static classes to implement the method of obtaining the client IP address

PHP uses static classes to implement the method of obtaining the client IP address

WBOY
Release: 2016-07-25 09:03:12
Original
1010 people have browsed it
  1. /**

  2. * Miscellaneous utility methods.
  3. */
  4. final class Utils {

  5. private function __construct() {

  6. }
  7. /**

  8. * Get IP address
  9. * @return string IP address string
  10. */
  11. public static function getIpAddress() {
  12. return $_SERVER["REMOTE_ADDR"];
  13. }
  14. }
  15. ?>

Copy the code

2. Call

  1. $last_login_ip = Utils::getIpAddress();
  2. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template