Current location - Quotes Website - Personality signature - What does getip () mean in php? What role does it play in development?
What does getip () mean in php? What role does it play in development?
Hi, a getip, there is no original function or method in PHP ... it belongs to its own package ... it is mainly used to get the ip address of the developing client, such as://to get the user IP.

Function getIP() {

If (! Empty ($ _ SERVER[\ "HTTP _ CLIENT _ IP \ "]){

$ CIP = $ _ SERVER[\ " HTTP _ CLIENT _ IP \ "];

} else if(! Empty ($ _ server [\ "http _ x _ forwarded _ for \"]) {

$ CIP = $ _ SERVER[\ " HTTP _ X _ FORWARDED _ FOR \ "];

} else if(! Empty ($_SERVER [\ "remote _ ADDR \ "]){

$cip = $_SERVER [\ "remote _ addr \"];

} Otherwise {

$ CIP =“”;

}

preg_match ( \"/[\d\。 ]{7, 15}/\ ",$cip,$ CIPS);

$cip = isset ( $cips [0])? $cips [0]:' unknown';

unset(CIPS);

Return to $ cip

}