This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:php [2021/04/14 02:57] nanodano |
programming:php [2022/03/13 19:00] (current) nanodano ↷ Links adapted because of a move operation |
||
---|---|---|---|
Line 17: | Line 17: | ||
</ | </ | ||
- | See the [[:web_servers|web servers]] page for more info on configuring | + | See the [[:web|web servers]] page for more info on configuring |
===== Built-in webserver ===== | ===== Built-in webserver ===== | ||
Line 213: | Line 213: | ||
$image-> | $image-> | ||
$image-> | $image-> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== JSON ==== | ||
+ | |||
+ | <code php json.php> | ||
+ | <?php | ||
+ | # PHP object -> JSON string | ||
+ | $json_string = json_encode([' | ||
+ | echo $json_string; | ||
+ | |||
+ | # JSON string -> PHP object | ||
+ | $json_string = ' | ||
+ | $my_array = json_decode($json_string); | ||
+ | print_r($my_array) | ||
+ | |||
+ | // Dump/read from file | ||
+ | file_put_contents(' | ||
+ | $my_array = json_decode(file_get_contents(' | ||
+ | print_r($my_array); | ||
</ | </ | ||
Line 402: | Line 422: | ||
*/ | */ | ||
</ | </ | ||
+ | |||
+ | |||