In this example, the best solution would be to use PHP's parse_url
method. This splits up the URL into an associative array. You would then build your final value by combining the scheme
with the host
:
if ( $parts = parse_url( "http://example.com/i/like/turtles.html" ) ) {
echo $parts[ "scheme" ] . "://" . $parts[ "host" ];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…