I've been beating my head against a wall all day and can't figure this one out. The code below worked perfectly in PHP5.2.4. However, I recently upgraded to PHP5.3.0 and this code no longer works. The function below accepts the path to a text file containing headers from a cUrl session (example attached). Basically this function opens to log file, looks for certain headers and captures some information from that line. When called on the attached file (or any log file for that matter), the following is output: array(2) { ["ResponseCode"]=> NULL ["ErrorMessage"]=> NULL } Which means that nothing is getting read from the file. Now, I'm going to qualify all of this by saying I'm running OSX Snow Leopard, so I'm fully prepared to believe that Apple fucked something up in it, as they have done to third party packages on other occasions in the past. Well... to be fair, they don't usually fuck up third party packages, rather they introduce "enhancements" to the OS that prevents certain packages from working correctly and could care less that they broke it. So did anything change in PHP5.3.0 that would preclude the code below from working? Am I going crazy? Or did Apple f*@# something up in this release? Thanks, Steve BEGIN CODE ========== function parseResponseHeaders($header_file) { $http_found = $error_found = false; $http_reponse = $error_message = NULL; $response = array(); $response['ResponseCode'] = NULL; $response['ErrorMessage'] = NULL; if (!is_file($header_file) || !is_readable($header_file)) { return $response; } $fin = fopen($header_file, 'r'); while ($line = fgets($fin)) { var_dump($line); if (substr($line, 0, 4) == 'HTTP') { $line_explode = explode(' ', $line); $response['ResponseCode'] = preg_replace('/\D/', '', $line_explode[1]); if ($response['ResponseCode'] != 100) { $http_found = true; } } if (substr($line, 0, 16) == 'X-Error-Message:') { $line_explode = explode(' ', $line); array_shift($line_explode); $response['ErrorMessage'] = join(' ', $line_explode); $error_found = true; } } fclose($fin); var_dump($response); return $response; }
HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Thu, 10 Sep 2009 20:57:43 GMT Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 PHP/5.2.8 X-Powered-By: PHP/5.2.8 Vary: Accept-Encoding Content-Length: 1630 Content-Type: text/html
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php