05 PHP Version 8 Home
MySQL Relational Database Mangement System
Back To Assignments
PHP 8.0 Documentation/Named Arguments
PHP 8.0 was a recent update of PHP that released in late November of 2020. The update contained major changes and new features, optimizations, and attributes among other things. Here I'll be describing three of the features that are new with PHP 8.0 along with the explanations from the PHP documentation. The first one is named arguments. Users are now able to specify required paramters in arguments and now can skip optional ones. Arguments are now also order-independent and self-documented.
Match Expression
Next is the new match expression feature. Because match is an expression, it can be stored in a variable or returned. It also doesn't need a 'break;' statement because it only supports single line epxressions. It also does strict comparisons. There is demo code that helps visualize and explain the feature and what the changes mean as well as how PHP worked before without the new feature through the provided link.
Nullsafe Operator
The last feature I'd like to bring up is the nullsafe operator. Instead of null check conditions, you can now use a chain of calls with the new nullsafe operator. When the evaluation of one element in the chain fails, the execution of the entire chain aborts and the entire chain evaluates to null. This means you can save a lot of time and code when having to perform nullchecks by using this new operator.
To Summarize
Like with many new iterations of things (except the Madden Franchise), improvements continue to be made. PHP 8.0 has a lot of helpful new features, attributes, and other improvements to help with consistency, error handling, and type system. PHP benefits from being open source because a lot of new ideas and intriguing insights are made constantly and added to the newest version of PHP, whether it be simple solutions to bugs or new features altogether. Hopefully, you and I (you, the reader) too can have an impact on PHP or any other open source langauge or program out there.