3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function rocket______get_domain( $url ) { if ( is_object( $url ) ) { $url = $url->post_title; } $url = str_replace( array( 'http://', 'https://' ), '', $url ); $url = 'http://'.$url; $urlobj = parse_url( str_replace( 'www.', '', $url ) ); $domain = $urlobj['host']; $return = false; if( preg_match( '/(?P<domain>[a-z0-9\-]{1,63}\.[a-z\.]{2,5})$/i', $domain, $regs ) ) // julio le 06/05/15 $return = $regs['domain']; if ( 'dev' == pathinfo( $return, PATHINFO_EXTENSION ) || 'localhost' == $return ) return 'dev'; return $return; } var_dump( rocket______get_domain( 'http://dq.dev' ) );
based on MQ7UO
Output for 4.3.3 - 7.2.0
string(3) "dev"
Output for 4.3.2
Notice: Undefined index: domain in /in/EG6EO on line 14 NULL
Output for 4.3.0 - 4.3.1
Notice: Undefined index: domain in /in/EG6EO on line 14
Process exited with code 139.