Skip to content

Commit d39a180

Browse files
committed
PHP5.3 compatibility
1 parent 51c4615 commit d39a180

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

QuickChart.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,15 @@ function getShortUrl() {
9393
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
9494
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
9595
$result = curl_exec($ch);
96+
97+
if ($result === false) {
98+
throw new Exception(curl_error($ch), curl_errno($ch));
99+
}
100+
96101
curl_close($ch);
97-
return json_decode($result, true)['url'];
102+
// Note: do not dereference json_decode directly for 5.3 compatibility.
103+
$ret = json_decode($result, true);
104+
return $ret['url'];
98105
}
99106

100107
function toBinary() {

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ $chart->toFile('/tmp/myfile.png')
121121

122122
Checkout the `examples` directory to see other usage.
123123

124+
## Note to PHP5 users
125+
126+
This package requires curl and json modules.

0 commit comments

Comments
 (0)