Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
PHP 7.3: A Look at JSON Error Handling
Jun 13, 2018 @ 15:18:53

On the Laravel News site there's a tutorial posted looking ahead at PHP 7.3 and some of the changes coming for JSON error handling.

One of the new features coming to PHP 7.3 is better error handling for json_encode() and json_decode(). The RFC was unanimously accepted by a 23 to 0 vote. Let’s take a look at how we handle JSON errors in <= PHP 7.2, and the new improvements coming in PHP 7.3.

They start with an example of how PHP developers would normally check for JSON parsing errors and the typical response when it fails. In the proposed functionality for PHP 7.3 and optional JSON_THROW_ON_ERROR would be added to throw a JsonException if there was an issue parsing the provided data. This also means that you no longer need to manually request the error message, it would just come through as a part of the standard exception. You can find out the full details on the change in the RFC.

tagged: php73 json parse error handling throwable exception feature rfc

Link: https://laravel-news.com/php-7-3-json-error-handling


Trending Topics: