Note that there are some explanatory texts on larger screens.

plurals
  1. POjson_decode own class - Warning: Depth must be greater than zero
    text
    copied!<p>Because I prefer a more object oriented approach I wrote my own json class to handle also json_last_error for decode and encode.</p> <p>Somehow I get a php warning for the depth property of the json_decode method.</p> <p>The PHP core api (eclipse PDT) for the json_decode method looks like the following:</p> <pre><code>function json_decode ($json, $assoc = null, $depth = null) {} </code></pre> <p>So far so good but if I write my own class like this:</p> <pre><code>function my_json_decode ($json, $assoc = null, $depth = null) { return json_decode($json, $assoc, $depth); } </code></pre> <p>and try to run it as follow:</p> <pre><code>$json = '{ "sample" : "json" }'; var_dump( my_json_decode($json) ); </code></pre> <p>I get the following warning:</p> <pre><code>Warning: json_decode(): Depth must be greater than zero in / </code></pre> <p>Did I miss anything? I thought if I pass null for a property to a method which set the property itself to null it should be fine?!</p> <p>Using: Server: Apache/2.2.22 (Unix) PHP/5.3.10</p> <p>Thanks for the help!</p> <hr> <p>[Edit] to clarify where my leak of understanding was:</p> <p>I am using Eclipse Indigo + PDT. The PDT PHP core api of org.eclipse.php.core.language is different from what php.net say about json_decode:</p> <p>json_decode org.eclipse.php.core.language:</p> <pre><code>json_decode ($json, $assoc = null, $depth = null) </code></pre> <p>json_decode php.net:</p> <pre><code>json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload