Pure PHP https://www.pure-php.de PHP powers the web Wed, 30 Mar 2011 19:26:05 +0000 en hourly 1 http://wordpress.org/?v=3.1 Reading HTTP Status Codes with PHP /archives/13 /archives/13#comments Mon, 04 May 2009 08:02:26 +0000 admin /?p=13 this morning I stumbled upon this blog post on phphatesme.com. The solution presented there 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.


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 morning I stumbled upon this blog post on phphatesme.com. The solution presented there 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.


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.

]]>
/archives/13/feed 0
PHP rules the web /archives/11 /archives/11#comments Tue, 10 Mar 2009 07:42:15 +0000 admin /?p=11 Ich hoffe, ihr verzeiht mit den provokativen Titel, aber da ist dran. PHP is the most important programming language for web applications. Das hat auch eine Studie von Evans Data Corporation, confirmed. Demnach ist PHP populärer als Ruby und Python. Nicht umsonst setzen die größten Web 2.0 Seiten, wie Facebook, Studivz, Wer-Kennt-wen, Wikipedia, WordPress.com rely on PHP.

]]>
Ich hoffe, ihr verzeiht mit den provokativen Titel, aber da ist dran. PHP is the most important programming language for web applications. Das hat auch eine Studie von Evans Data Corporation, confirmed. Demnach ist PHP populärer als Ruby und Python. Nicht umsonst setzen die größten Web 2.0 Seiten, wie Facebook, Studivz, Wer-Kennt-wen, Wikipedia, WordPress.com rely on PHP.

]]>
/archives/11/feed 0
Google Charts API with PHP /archives/10 /archives/10#comments Thu, 24 Apr 2008 06:47:13 +0000 admin /?p=10 Ludwig Pettersson has written a class that allows you to conveniently create charts with PHP and Google Charts API.
Google Charts is a simple API that lets you create various types of charts. To create a chart, you just need to call a URL with specific parameters and you receive an image back.

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:
Chart

]]>
Ludwig Pettersson has written a class that allows you to conveniently create charts with PHP and Google Charts API.
Google Charts is a simple API that lets you create various types of charts. To create a chart, you just need to call a URL with specific parameters and you receive an image back.

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:
Chart

]]>
/archives/10/feed 0
Calculating Distance with SQL /archives/9 /archives/9#comments Wed, 23 Apr 2008 07:59:55 +0000 admin /?p=9 It sometimes makes work a bit easier when you calculate certain operations directly with SQL.
A practical example is the calculation of distances. In some projects I calculated this with PHP.

It can also be done directly with SQL
SELECT *, SQRT(POW(L2.lat - L1.lat, 2) + POW(L2.lng - L1.lng, 2)) AS Distance

Via

]]>
It sometimes makes work a bit easier when you calculate certain operations directly with SQL.
A practical example is the calculation of distances. In some projects I calculated this with PHP.

It can also be done directly with SQL
SELECT *, SQRT(POW(L2.lat - L1.lat, 2) + POW(L2.lng - L1.lng, 2)) AS Distance

Via

]]>
/archives/9/feed 0
Sun Buys MySQL /archives/7 /archives/7#comments Wed, 16 Jan 2008 15:06:16 +0000 admin /archives/7 Sun Buys MySQL AB for approximately one billion US dollars. The news is quite significant. I have already written about it here. But what does this mean for PHP?
Could it be that more attention will be paid to Java compatibility? Possibly.
If anyone has this concern, MySQL will continue to remain open source. However, Sun could use this to push its programming language Java more aggressively, as Java has recently been losing ground on the web to PHP and Ruby.

More at Golem und Heise.

]]>
Sun Buys MySQL AB for approximately one billion US dollars. The news is quite significant. I have already written about it here. But what does this mean for PHP?
Could it be that more attention will be paid to Java compatibility? Possibly.
If anyone has this concern, MySQL will continue to remain open source. However, Sun could use this to push its programming language Java more aggressively, as Java has recently been losing ground on the web to PHP and Ruby.

More at Golem und Heise.

]]>
/archives/7/feed 0
Zend_Service_SlideShare accepted into the Zend Framework incubator /archives/5 /archives/5#comments Tue, 11 Dec 2007 09:43:09 +0000 admin /?p=5 John Coggeshall‘s Zend_Service_SlideShare ist accepted into the Zend Framework incubator. That is a good news, but why doesn’t anyone wirtes a Zend_Service_Paypal?

]]>
John Coggeshall‘s Zend_Service_SlideShare ist accepted into the Zend Framework incubator. That is a good news, but why doesn’t anyone wirtes a Zend_Service_Paypal?

]]>
/archives/5/feed 0