I am currently trying to learn JSON and it is kicking my proverbial behind at the moment.
With a normal variable I was able to encode it fine and then echo to see the JSON string.
However I am wanting to encode an object but its not working:
Class tariff
{
var $preset_name;
var $name;
var $net;
var $inclusive;
var $length;
var $data;
function __construct()
{
$preset_name = "Orange-1gb-ECL";
$name = array ("1312" => "Orange 1gb Eclipse");
$net = array ("12312" => "Orange");
$inclusive = array ("1312" => "1GB");
$length = array ("12312" => "12 Months");
$data = array ("12312" => "12p per mb");
}
}
$tariff = new tariff();
$tariff = json_encode($tariff);
echo $tariff;
return 0;
My output is:
{"preset_name":null,"name":null,"net":null,"inclusive":null,"length":null,"data":null}
Ive tried googling and searching on here but can't find my answer!
Help me Obi Wan, your my only hope!