mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 04:01:47 +00:00
Fix undefined function json_last_error_msg() for older versions of php
This commit is contained in:
+6
-1
@@ -145,7 +145,12 @@ class Curl
|
||||
preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
|
||||
$data = json_encode($data);
|
||||
if (!(json_last_error() === JSON_ERROR_NONE)) {
|
||||
throw new \ErrorException('json_encode error: ' . json_last_error_msg());
|
||||
if (function_exists('json_last_error_msg')) {
|
||||
$error_message = 'json_encode error: ' . json_last_error_msg();
|
||||
} else {
|
||||
$error_message = 'json_encode error';
|
||||
}
|
||||
throw new \ErrorException($error_message);
|
||||
}
|
||||
} else {
|
||||
// Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch,
|
||||
|
||||
Reference in New Issue
Block a user