Open main menu

Changes

553 bytes added ,  17:40, 1 July 2015
add note about JSON
== Language Features ==
 
=== Magic Methods ===
* [https://github.com/guidovanbiemen/setngeti SetnGeti] - an implementation of Magic Methods for getting and setting based on traits and DocBlock comments.
* [https://cspray.github.io/2012/05/13/stop-calling-them-getters-setters Don't do it the wrong way]
 
=== JSON ===
 
With <code>[https://php.net/manual/en/function.json-decode.php json_decode()]</code>, you either get an object, or using the optional second
parameter, you can force the return value to an array. In the former case, you access the content using object notation. In the latter case, you use array notation.
ie.
<source lang="php">
$data = json_decode($data);
$version = $data->query->general->generator;
// or
$data = json_decode($data, true);
$version = $data['query']['general']['generator'];
 
</source>
 
[[Category:PHP]]
4,558

edits