w3resource

PHP JSON - Exercises, Practice, Solution

PHP JSON [ 4 exercises with solution]

1. Write a PHP script to decode a JSON string. Go to the editor
Click me to see the solution

2. Write a PHP script to decode large integers. Go to the editor
Sample integer :
{"number": 123456789012345678901234567890}
Click me to see the solution

3. Write a PHP script to get JSON representation of a value from an array. Go to the editor
Click me to see the solution

4. Write a PHP function to display JSON decode errors. Go to the editor
Click me to see the solution

PHP Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



PHP: Tips of the Day

PHP: PHPDoc type hinting for array of objects?

Use:

/* @var $objs Test[] */
foreach ($objs as $obj) {
    // Typehinting will occur after typing $obj->
}

when typehinting inline variables, and

class A {
    /** @var Test[] */
    private $items;
}

Ref : https://bit.ly/31a2QJN