My first question at stackoverflow:
I have a class that loads JSON data.
Here is the class:
class example {
public $url = array(
"location" => "http://www.example.com/location/?{city}.json",
);
public $location = array();
public function load($url_template = NULL, $params = array(), $overwrite = false) {
$this->$url_template = $this->load_json(
$this->build_url($url_template, $params)
);
}
public function load_json($url) {
return json_decode($url);
}
}
Outside I use:
$example = new example();
$example->load("location", array(
'city' => 'Boston',
));
When I do
echo $example->country->name;
echo $example->blabla->blub;
I want an information like
$example->country->name was called and the returned value is "Boston"
$example->blabla->blub was called but property "blabla" is not existing and property "blub" is also not existing so the returned value is "n/a"
within the class.
Thank you, harry_bo