Ip and ips, both of which indicate undefined: NOTIC: [8] Undefinedvariable: ipNOTIC: [8] Undefinedvariable: ips. Who can help you change it ~~ {Code...} ip and ips, both of which indicate undefined:
NOTIC: [8] Undefined variable: ip
NOTIC: [8] Undefined variable: ips
Who can help me change it ~~
Function Getip () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ ip = $ _ SERVER ["HTTP_CLIENT_IP"];} if (! Empty ($ _ SERVER ['HTTP _ X_FORWARDED_FOR ']) {// get proxy ip $ ips = explode (',', $ _ SERVER ['HTTP _ X_FORWARDED_FOR ']);} if ($ ip) {$ ips = array_unshift ($ ips, $ ip );} $ count = count ($ ips); for ($ I = 0; $ I <$ count; $ I ++) {if (! Preg_match ("/^ (10 | 172 \. 16 | 192 \. (168 )\. /I ", $ ips [$ I]) {// exclude LAN ip $ ip = $ ips [$ I]; break ;}$ tip = $ ip? $ Ip: $ _ SERVER ['remote _ ADDR ']; if ($ tip = "127.0.0.1 ") {// obtain the local real IP return $ this-> get_onlineip () ;}else {return $ tip ;}}
Reply content:
Ip address and ips, both of which are undefined:
NOTIC: [8] Undefined variable: ip
NOTIC: [8] Undefined variable: ips
Who can help me change it ~~
Function Getip () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ ip = $ _ SERVER ["HTTP_CLIENT_IP"];} if (! Empty ($ _ SERVER ['HTTP _ X_FORWARDED_FOR ']) {// get proxy ip $ ips = explode (',', $ _ SERVER ['HTTP _ X_FORWARDED_FOR ']);} if ($ ip) {$ ips = array_unshift ($ ips, $ ip );} $ count = count ($ ips); for ($ I = 0; $ I <$ count; $ I ++) {if (! Preg_match ("/^ (10 | 172 \. 16 | 192 \. (168 )\. /I ", $ ips [$ I]) {// exclude LAN ip $ ip = $ ips [$ I]; break ;}$ tip = $ ip? $ Ip: $ _ SERVER ['remote _ ADDR ']; if ($ tip = "127.0.0.1 ") {// obtain the local real IP return $ this-> get_onlineip () ;}else {return $ tip ;}}
If you only want to ignore this problem, lower the error reporting level, set error_reporting = E_ERROR in php. ini, or directly set it in php.error_reporting(E_Error);
ThinkPHP solves this problem. TP does not solve these problems. To solve this problem, you must first verify it through isset...
Determine whether the two variables have values. If yes, assign values. If no value exists, set it to null. Please try this.