- var_dump: documentation ( source)
- parse_url: documentation ( source)
<?php
function a()
{
return 'http://localhost:80';
}
$hostname = a();
if ( !$port = parse_url( $hostname, PHP_URL_HOST & PHP_URL_PORT ) ) {
var_dump( "oops" );
}
echo $port;