<?php
if (! isset( $_GET['URL'] ) ) {
$_GET['URL'] = 'https://www.example.com/';
}
$options = 'time_namelookup:%{time_namelookup}\n'
. 'time_pretransfer:%{time_pretransfer}\n'
. 'time_redirect:%{time_redirect}\n'
. 'time_total:%{time_total}';
$sys = 'LANG=C curl -I --write-out "'
. $options . '" '
. escapeshellarg( trim ( $_GET['URL'] ) )
. ' 2> /dev/null | grep -P \'^time_\';'
;
$ret = `$sys`;
$ar = explode( "\n", $ret );
$erg = [];
foreach ( $ar as $row ) {
$row = trim($row);
if ( $row ) {
list( $name, $value ) = explode( ':', $row, 2);
$erg[$name] = $value;
}
}
print_r( $erg );
Array
(
[time_namelookup] => 0.004270
[time_pretransfer] => 0.458685
[time_redirect] => 0.000000
[time_total] => 0.604829
)