×ðÁú¿­Ê±

thinkphp»ñÈ¡ÇëÇóip

ÔÚweb¿ª·¢ÖÐ £¬Í¨³£ÐèÒª»ñÈ¡¿Í»§¶ËµÄipµØµã¡£¶øÔÚʹÓÃphp¿ò¼Üthinkphpʱ £¬»ñÈ¡ÇëÇóipµØµãºÜÊÇÈÝÒס£±¾ÎĽ«¼òÆÓÏÈÈÝÔõÑùÔÚthinkphp¿ò¼ÜÖлñÈ¡ÇëÇóipµØµã¡£

Ò»¡¢»ñÈ¡¿Í»§¶ËIPµØµã

»ñÈ¡¿Í»§¶ËIPµØµãÔÚÈκÎWeb¿ª·¢Öж¼ÊǽÏÁ¿³£¼ûµÄÐèÇó¡£ÔÚThinkPHP¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ´úÂëÀ´»ñÈ¡¿Í»§¶ËIPµØµã£º

$request =     hinkRequest::instance();
$ip = $request->ip();

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬ hinkRequest::instance()»ñÈ¡ÇëÇóʵÀý £¬$request->ip()»ñÈ¡ÇëÇóIPµØµã¡£

¶þ¡¢»ñÈ¡¿Í»§¶ËÕæʵIPµØµã

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÓÉÓÚ¿Í»§¶ËIPµØµã¿ÉÒÔºÜÈÝÒ×αÔì £¬Òò´ËÔÚijЩ³¡¾°ÏÂÐèÒª»ñÈ¡¿Í»§¶ËÕæʵIPµØµã¡£´Ëʱ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý»ñÈ¡HTTPÍ·ÖеÄX-Forwarded-ForÀ´»ñÈ¡¡£

$request =     hinkRequest::instance();
$ip = $request->header('x-forwarded-for');

µÇ¼ºó¸´ÖÆ

ÕâÀïµÄx-forwarded-forÊÇHTTPÍ·ÖеÄÒ»¸ö×ֶΠ£¬ËüÍùÍù°üÀ¨ÁË¿Í»§¶ËµÄÕæʵIPµØµã£¨ÈôÊÇÓжà¸öIPµØµã £¬ÔòÒÔ¶ººÅÍÑÀ룩¡£ÐèҪעÖصÄÊÇ £¬ÓÐЩÊðÀíЧÀÍÆ÷²»»áÔÚHTTPÍ·ÖÐÌí¼Óx-forwarded-for×ֶΠ£¬Òò´ËÔÚijЩÇéÐÎÏÂÕâÖÖÒªÁì¿ÉÄÜÎÞ·¨»ñÈ¡¿Í»§¶ËÕæʵIPµØµã¡£

Èý¡¢»ñȡЧÀÍÆ÷IPµØµã

ÓÐʱ¼äÎÒÃÇÐèÒª»ñȡЧÀÍÆ÷IPµØµã £¬ºÃ±ÈÔÚÈ·¶¨Ä¿½ñÍøÕ¾ÔËÐÐÇéÐÎʱ¡£ÔÚThinkPHP¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ´úÂëÀ´»ñȡЧÀÍÆ÷IPµØµã£º

$server_ip = gethostbyname($_SERVER["SERVER_NAME"]);

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬$_SERVER[“SERVER_NAME”]ÌåÏÖÄ¿½ñЧÀÍÆ÷µÄÓòÃû £¬gethostbynameº¯Êý»á·µ»Ø¸ÃÓòÃû¶ÔÓ¦µÄIPµØµã¡£

ËÄ¡¢»ñÈ¡Ä¿½ñ»á¼ûµÄURL

ÔÚWeb¿ª·¢ÖÐ £¬»ñÈ¡Ä¿½ñÒ³ÃæµÄURLµØµã·Ç¾­³£¼û¡£ÔÚThinkPHP¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ´úÂë»ñÈ¡Ä¿½ñÒ³ÃæµÄURL£º

$url = request()->url(true);

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬request()ÌåÏÖÇëÇ󹤾ßʵÀý £¬url(true)ÌåÏÖ»ñÈ¡ÍêÕûµÄURLµØµã¡£ÈôÊDz»×ª´ï²ÎÊý £¬ÔòĬÈÏÖ»»ñÈ¡URL·¾¶²¿·Ö £¬²»°üÀ¨ÓòÃûºÍЭÒéµÈÐÅÏ¢¡£

Î塢С½á

ÔÚThinkPHP¿ò¼ÜÖÐ £¬»ñÈ¡ÇëÇóIPµØµã¡¢¿Í»§¶ËÕæʵIPµØµã¡¢Ð§ÀÍÆ÷IPµØµãºÍÄ¿½ñ»á¼ûµÄURLºÜÊǼòÆÓ¡£Í¨¹ýÉÏÊö´úÂë £¬ÎÒÃÇ¿ÉÒÔÇáËɵػñÈ¡ÕâЩ³£ÓÃÐÅÏ¢ £¬Îª×ðÁú¿­Ê±Web¿ª·¢ÊÂÇéÌṩÁ˱ã½Ý¡£

ÒÔÉϾÍÊÇthinkphp»ñÈ¡ÇëÇóipµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿