<?php
mix parse_url ( str $url , int $component = -1 )
where,
$url = The URL to be parsed
Inválid characters are replaced by underline, ( _ )
$component = One of the URL component
( SEE the below TABLE )
?>
CONSTANT NAME | VALUE | MEANING |
PHP_URL_SCHEME | 0 | scheme |
PHP_URL_HOST | 1 | host |
PHP_URL_PORT | 2 | port |
PHP_URL_USER | 3 | user |
PHP_URL_PASS | 4 | pass |
PHP_URL_PATH | 5 | path |
PHP_URL_QUERY | 6 | query AFTER the ? |
PHP_URL_FRAGMENT | 7 | fragment AFTER the # |
ed48 |
<?php
$urltoparse01 = 'https://trip.ed48.com/trip/?tlb=15#6';
echo parse_url($urltoparse01, PHP_URL_SCHEME);
echo '<br>' . parse_url($urltoparse01, PHP_URL_HOST);
echo '<br>' . parse_url($urltoparse01, PHP_URL_QUERY);
?>
<?php
$urltoparse02 = 'https://trip.ed48.com/trip/?tlb=15#6';
echo '<br><br><pre>';
var_dump(parse_url($urltoparse02));
echo '</pre>';
?>
<?php
$urltoparse03 = 'https://hirotur.com.br/paginas/informacoes-sobre-destinos/';
$arr03 = [ 0 => 'PHP_URL_SCHEME', 1 => 'PHP_URL_HOST',
2 => 'PHP_URL_PORT', 3 => 'PHP_URL_USER',
4 => 'PHP_URL_PASS', 5 => 'PHP_URL_PATH',
6 => 'PHP_URL_QUERY', 7 => 'PHP_URL_FRAGMENT' ];
for($i=0; $i < 8; $i++)
{
echo $arr03[$i] . '<br>';
var_export(parse_url($urltoparse03, $i));
echo '<br><br>';
}
?>