Estrapolare il nome del dominio da un URL

Dato un indirizzo internet (URL o URI) ecco come estrarne il dominio di appartenenza, in PHP:

// trova il nome del sito
$url="http://nome del sito...";
$mystring = substr($url, 7);
$pos = strpos($mystring, '/');
$sito = substr($mystring, 0, $pos);

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato.

You can add images to your comment by clicking here.