<code><span>// 获取IP地址</span> function GetIP() { <span>if</span>(<span>getenv</span>(<span>'HTTP_CLIENT_IP'</span>) && strcasecmp(<span>getenv</span>(<span>'HTTP_CLIENT_IP'</span>), <span>'unknown'</span>)) { <span>$thisip</span> = <span>getenv</span>(<span>'HTTP_CLIENT_IP'</span>); } elseif(<span>getenv</span>(<span>'HTTP_X_FORWARDED_FOR'</span>) && strcasecmp(<span>getenv</span>(<span>'HTTP_X_FORWARDED_FOR'</span>), <span>'unknown'</span>)) { <span>$thisip</span> = <span>getenv</span>(<span>'HTTP_X_FORWARDED_FOR'</span>); } elseif(<span>getenv</span>(<span>'REMOTE_ADDR'</span>) && strcasecmp(<span>getenv</span>(<span>'REMOTE_ADDR'</span>), <span>'unknown'</span>)) { <span>$thisip</span> = <span>getenv</span>(<span>'REMOTE_ADDR'</span>); } elseif(isset(<span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>]) && <span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>] && strcasecmp(<span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>], <span>'unknown'</span>)) { <span>$thisip</span> = <span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>]; } preg_match(<span>"/[\d\.]{7,15}/"</span>, <span>$thisip</span>, <span>$thisips</span>); <span>$thisip</span> = <span>$thisips</span>[<span>0</span>] ? <span>$thisips</span>[<span>0</span>] : <span>'unknown'</span>; <span>return</span><span>$thisip</span>; }</code>
已經測試過了。可以取得到真實的IP位址! TCP/IPv4
可以直接放程式碼裡用就行了 。不用謝。請叫我『雷鋒』
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });以上就介紹了無法取得ip位址 PHP取得準確的IP位址的方法,包括了無法取得ip位址方面的內容,希望對PHP教學有興趣的朋友有所幫助。