- var_dump: documentation ( source)
- parse_url: documentation ( source)
<?php
var_dump(
parse_url( 'http://127.0.0.1:80' ),
parse_url( 'http://[::1]:80' ),
parse_url( 'http://127.0.0.1' ), // Local IPv4
parse_url( 'http://104.205.87.98' ), // Public IPv4
parse_url( 'http://201.152.36.103:58749' ), // IPv4 with port
parse_url( 'http://1fff:0:a88:85a3::ac1f' ), // IPv6
parse_url( 'http://[1fff:0:a88:85a3::ac1f]:8001' ) // IPv6 with port
);