From 9177d72bea9c1da3f0c4bae5a80e19e3df2850cf Mon Sep 17 00:00:00 2001 From: Mikael Roos Date: Wed, 26 Nov 2014 14:45:38 +0100 Subject: [PATCH] Check if constants exists. Fix #42 --- CImage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CImage.php b/CImage.php index af97cad..8e79d7e 100644 --- a/CImage.php +++ b/CImage.php @@ -1735,7 +1735,12 @@ class CImage $details['height'] = $this->height; $details['aspectRatio'] = round($this->width / $this->height, 3); - return json_encode($details, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $options = null; + if (defined("JSON_PRETTY_PRINT") && defined("JSON_UNESCAPED_SLASHES")) { + $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES; + } + + return json_encode($details, $options); }