PHP version 8.0 has arrived, bringing with it a major update to the 25-year-old programming language.
PHP 8.0 introduces a number of new features to the language, most notably union types, a Just In Time (JIT) complier, nullsafe operator, attributes and ‘named arguments.’
SEE: Meet the hackers who earn millions for saving the web, one bug at a time (cover story PDF) (TechRepublic)
The JIT compiler is designed to bring performance improvements to web applications by turning code into instructions for the CPU at runtime. Meanwhile, union types is a feature that allows data of more than one type to be held by a variable.
Named arguments allow developers to assign values to a function by specifying the value name, allowing optional parameters to be ignored.
Alongside these, version 8.0 of PHP brings optimizations and enhancements to the language’s type system, syntax, error handling and consistency.
PHP was created by Danish-Canadian programmer Rasmus Lerdorf in 1994, with Lerdorf releasing the language’s source code to the public one year later. By 1998, PHP was reportedly being use by around 1% of all web domains.
SEE: Linux commands for user management (TechRepublic Premium)
It is a backend programming language, meaning it’s primarily used to handle interconnections between servers and data handling, as opposed to GUI or frontend interfaces.
While PHP is still widely used for building web applications, in recent years more modern programming languages have overtaken it in terms of its adoption by developers.
PHP programmer and stitcher.io developer, Brent Roose, said in a blog post in January that the language had acquired “a reputation of messy codebases, inexperienced developers, insecure code, and [an] inconsistent core library” over the years, though added that it still offered “a great choice for web development if used wisely and correctly”.
SEE: Top 5 programming languages web developers should know (free PDF) (TechRepublic)
Conversely, a Redmonk survey from July 2020 puts PHP as the fourth most popular language, whereas Stack Overflow’s 2020 developer survey ranks it as the sixth “most dreaded” programming language amongst developers. Needless to say, the results of the many programming language surveys and indexes available online don’t always agree.
Commenting on PHP 8.0, Roose noted that the latest version of the language may require developers to review code for any breaking changes.
Stefan Priebsch, co-founder and principal consultant at the PHP Consulting Company, advised that migration to PHP 8 “requires more preparation” than the upgrade from PHP 5.x to PHP 7, due to legacy issues that had been removed from the language.
Speaking to German publication, Heise, Preibsch said: “I advise you to prepare your existing applications step by step for use with PHP 8 before planning the actual migration. On the other hand, if you develop a new application, there is nothing to be said against using PHP 8 right from the start and benefiting from the new language features.”