PHP JSON - Exercises, Practice, Solution
PHP JSON [ 4 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a PHP script to decode a JSON string.
Click me to see the solution
2. Write a PHP script to decode large integers.
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.
Click me to see the solution
4. Write a PHP function to display JSON decode errors.
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: Pass a PHP string to a JavaScript variable (and escape newlines)
<script> var myvar = <?php echo json_encode($myVarValue); ?>; </script>
Using json_encode() requires:
- PHP 5.2.0 or greater
- $myVarValue encoded as UTF-8 (or US-ASCII, of course)
Since UTF-8 supports full Unicode, it should be safe to convert on the fly.
Note that because json_encode escapes forward slashes, even a string that contains </script> will be escaped safely for printing with a script block.
Ref : https://bit.ly/34f0Dym
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook