#4 ✓resolved
Chris Barnett

json function only works with PHP 5.3

Reported by Chris Barnett | May 28th, 2009 @ 07:42 AM | in Release 0.3 - Citronnade

in limonade.php:

function json($data, $json_option = 0)
{
   header('Content-Type: application/x-javascript; charset='.strtolower(option('encoding')));
   return json_encode($data, $json_option);
}

This fails in PHP versions prior to 5.3, where there was no second parameter to json_encode.

A simple (but ugly) fix would be:

function json($data, $json_option = 0)
{
   header('Content-Type: application/x-javascript; charset='.strtolower(option('encoding')));
   if(version_compare(PHP_VERSION, '5.3.0', '>=')) {
     return json_encode($data, $json_option);
   } else {
     return json_encode($data); 
   }
}

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Limonade is a PHP micro-framework.

People watching this ticket

Tags

Referenced by

Pages