Created
December 9, 2012 14:18
-
-
Save jamesrwhite/4245135 to your computer and use it in GitHub Desktop.
cURL Headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $curl = curl_init('http://123123123123123123123123213w.com'); | |
| curl_setopt_array($curl, array( | |
| CURLOPT_HEADER => true, | |
| CURLOPT_NOBODY => true, | |
| CURLOPT_RETURNTRANSFER => true, | |
| )); | |
| // Get the headers | |
| $headers = curl_exec($curl); | |
| // Split by new lines into an array | |
| $headers = explode(PHP_EOL, $headers); | |
| // Remove empty lines | |
| $headers = array_filter($headers, function($value) { | |
| return !empty($value) and !in_array($value, array("\r", "\n")); | |
| }); | |
| print_r($headers); |
Author
May try reinstall php again, see if that solves the problem. Thanks for the help :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Weird. For me it's an empty array. I've tried from my laptop and vps as well.