File tree 1 file changed +17
-0
lines changed
Filter options
1 file changed +17
-0
lines changed
Original file line number Diff line number Diff line change @@ -361,6 +361,23 @@ analysis purposes. Use the ``anonymize()`` method from the
361
361
$anonymousIpv6 = IpUtils::anonymize($ipv6);
362
362
// $anonymousIpv6 = '2a01:198:603:10::'
363
363
364
+ Check if an IP belongs to a private subnet
365
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366
+
367
+ If you need to know if an IP address belongs to a private subnet, you can
368
+ use the ``isPrivateIp() `` method from the
369
+ :class: `Symfony\\ Component\\ HttpFoundation\\ IpUtils ` to do that::
370
+
371
+ use Symfony\Component\HttpFoundation\IpUtils;
372
+
373
+ $ipv4 = '192.168.1.1';
374
+ $isPrivate = IpUtils::isPrivateIp($ipv4);
375
+ // $isPrivate = true
376
+
377
+ $ipv6 = '2a01:198:603:10:396e:4789:8e99:890f';
378
+ $isPrivate = IpUtils::isPrivateIp($ipv6);
379
+ // $isPrivate = false
380
+
364
381
Accessing other Data
365
382
~~~~~~~~~~~~~~~~~~~~
366
383
You can’t perform that action at this time.
0 commit comments