{"id":6529,"date":"2015-11-13T17:26:37","date_gmt":"2015-11-13T11:26:37","guid":{"rendered":"http:\/\/shra.ru\/?p=6529"},"modified":"2015-11-13T17:26:37","modified_gmt":"2015-11-13T11:26:37","slug":"validator-ip-adresa-na-php","status":"publish","type":"post","link":"https:\/\/shra.ru\/2015\/11\/validator-ip-adresa-na-php\/","title":{"rendered":"\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 ip \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0430 PHP"},"content":{"rendered":"
\u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u0435\u043b\u043f\u0435\u0440\u0430-\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 PHP \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 ip \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n
<\/p>\n
\/** \r\n * \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0438\u0434\u0443 ip \u0430\u0434\u0440\u0435\u0441\u0430\r\n * @return bool\r\n *\/\r\nfunction is_valid_ip($ip) {\r\n $ipv4 = '[0-9]{1,3}(\\.[0-9]{1,3}){3}';\r\n $ipv6 = '[0-9a-fA-F]{1,4}(\\:[0-9a-fA-F]{1,4}){7}';\r\n return preg_match(\"\/^($ipv4|$ipv6)\\$\/\", trim($ip));\r\n}<\/pre>\n\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0430 ip-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c ipv4 \u0438\u043b\u0438 ipv6. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n
\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 (\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b<\/a>), \u0442\u0430\u043a \u0438 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n","protected":false},"excerpt":{"rendered":"
\u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u0435\u043b\u043f\u0435\u0440\u0430-\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 PHP \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 ip \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[39],"class_list":["post-6529","post","type-post","status-publish","format-standard","hentry","category-php","tag-validator"],"acf":[],"yoast_head":"\n
\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 ip \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0430 PHP<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n