Skip to content

Instantly share code, notes, and snippets.

@christeredvartsen
Created September 19, 2013 08:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christeredvartsen/6620626 to your computer and use it in GitHub Desktop.
Save christeredvartsen/6620626 to your computer and use it in GitHub Desktop.
Fetch the reason phrase with curl in PHP
<?php
$c = curl_init('http://www.vg.no');
curl_setopt_array($c, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
));
$data = curl_exec($c);
preg_match('#^HTTP/1.(?:0|1) [\d]{3} (.*)$#m', $data, $match);
echo trim($match[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment