Status code of a web page

This example will return the status code of the web page using PHP and CuRL. These type of routines are useful for example if you were to check the status of your site and say send an email the moment it was down or not responding.

<?php
//google
$curl = curl_init(‘http://www.google.com/’);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($curl);
//dump information about the
print(“STATUS CODE: ” . curl_getinfo($curl, CURLINFO_HTTP_CODE) .'<br>’);
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*