Member-only story
Exploring the New Features and Enhancements in PHP 8.3: A Deep Dive into the Latest Updates (Part 1)
Hi to all php lover developers, in this article i will try to explain new features of newest version of PHP (8.3). There are many new features in 8.3 and this makes my default coding language more elegant and developer friendly. Nowadays php can easily use on desktop programming with Native PHP. Of course there were many other tools for using php in Desktop programming but i felt Native PHP is more cool then them. Anyway lets start diving to our new features.
1. Json Validation
I bet all of us try to validate a string if it is a json or not in sometime while developing new projects. This feature adds native method to php for validating string if it is a json or not. I know that’s very cool addition.
$json = '{ "example": "title" }';
$is_json = false;
if (json_validate($json)) {
// Valid JSON.
$is_json = true;
}
// Or better way
$is_json = json_validate($json);
Currently, most PHP programmers use the
json_decode()
function for this task, but this uses memory and processing power that isn’t required for just checking validity. There will be no need to usejson_decode
for validating a json string.