public static function getHttpCode( $url )
{
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return $info['http_code'];
}
for reading HTTP status codes works, but is not ideal. Moreover, the cURL extension is not installed by default at every web host.
It can be done much more simply.
$info = get_headers( $url );
$status_code = $info[0];
get_headers gibt fast alle Header-Infos in ein Array zurück.
]]>
public static function getHttpCode( $url )
{
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return $info['http_code'];
}
for reading HTTP status codes works, but is not ideal. Moreover, the cURL extension is not installed by default at every web host.
It can be done much more simply.
$info = get_headers( $url );
$status_code = $info[0];
get_headers gibt fast alle Header-Infos in ein Array zurück.
]]>This is greatly simplified with a PHP class.
$data = array(
'IE7' => 22,
'IE6' => 30.7,
'IE5' => 1.7,
'Firefox' => 36.5,
'Mozilla' => 1.1,
'Safari' => 2,
'Opera' => 1.4,
);
$chart = new googChart();
$chart->setChartAttrs( array(
'type' => 'pie',
'data' => $data,
'size' => array( 300, 200 )
));
echo $chart;
Die Ausgabe:
This is greatly simplified with a PHP class.
$data = array(
'IE7' => 22,
'IE6' => 30.7,
'IE5' => 1.7,
'Firefox' => 36.5,
'Mozilla' => 1.1,
'Safari' => 2,
'Opera' => 1.4,
);
$chart = new googChart();
$chart->setChartAttrs( array(
'type' => 'pie',
'data' => $data,
'size' => array( 300, 200 )
));
echo $chart;
Die Ausgabe:
It can also be done directly with SQL
SELECT *, SQRT(POW(L2.lat - L1.lat, 2) + POW(L2.lng - L1.lng, 2)) AS Distance
It can also be done directly with SQL
SELECT *, SQRT(POW(L2.lat - L1.lat, 2) + POW(L2.lng - L1.lng, 2)) AS Distance