<?php
public function jsonDecode() {
$file = file_get_contents(__DIR__ . '../Data/modAmmo.json');
$json=json_decode($file);
return $json;
}
var_dump(jsonDecode());
?>
O ile się orientuję, to nie ma takiej funkcji jak json_file_decode() i trzeba ją samemu napisać. Przykład:
file1.json:
{ "abc":5}
file2.php:
<?php
function json_file_decode($file) {
return json_decode(file_get_contents($file));
}
function jsonDecode() {
return json_file_decode('file1.json');
// U Ciebie linia powyższa powinna być chyba zamieniona na tę:
// return json_file_decode(__DIR__ . '../Data/modAmmo.json');
}
// var_dump(jsonDecode());
echo jsonDecode()->abc;
// Output: 5
?>