I\'m trying echo the contents of an object in a JSON format. I\'m quite unexperienced with PHP and I was wondering if there is a predefined function to do this (like json_en
You'll need to make your variable public, in order for them to appear on json_encode().
json_encode()
Also, the code you're looking for is
public function toJSON(){ return json_encode($this); }