public static function error_handling($handling = PHR_ERROR_TEXT) { switch ($handling) { case PHR_ERROR_NONE: self::$exceptions = false; break; case PHR_ERROR_TEXT: self::$exceptions = true; self::$html_exceptions = false; break; case PHR_ERROR_HTML: self::$exceptions = true; self::$html_exceptions = true; break; default: self::throw_error('Error handling type given is unrecognized', E_USER_WARNING); break; } }
<?php include "../src/PHPHttpRequest.php"; // Set error handling error_reporting(E_ALL | E_STRICT); PHPHttpRequest::error_handling(PHR_ERROR_HTML); // Make the request $phr = new PHPHttpRequest(); $phr->open('GET', 'http://www.google.com'); $phr->send(); if ($phr->error_code) { die('error'); } // Output the response foreach ($phr->get_all_response_headers() as $name => $value) { header($name . ': ' . $value); } echo $phr->response_text; /* End of file index.php */