New features in PHP 8

Conversion Work

Stricter Reporting Requirements

If you call existing scripts in PHP 8, you can expect numerous error messages. Besides some incompatible changes, the main reason for these errors is stricter handling. From now on, the error report level E_ALL will be used by default. Additionally, the @ operator can be used to suppress fatal errors. Developers must also be prepared for SQL errors when connecting to databases via the PDO interface: Error handling now uses exception mode by default (PDO::ERRMODE_EXCEPTION).

Arithmetic and bitwise operators throw a TypeError if one of the operands is an array, a resource, or not an overloaded object. One exception occurs if you merge two arrays using array + array. Division by zero throws a DivisionByZeroError in PHP 8.

Finally, PHP 8 removes some functions and language constructs already tagged as deprecated in version 7.x. The PHP developers meticulously list all incompatible changes in a long document online [5]. If you need to maintain existing PHP code, you will definitely want to check out this document.

Conclusions

PHP 8 includes many useful new features that make the developer's life easier and provide for more compact code. In particular, the new match, Constructor Property Promotion, and attributes should quickly find many friends. In addition, PHP 8 cautiously throws out some outdated behaviors and constructs. Existing PHP applications, however, will most likely need to be adapted as a result. Whether the JIT compiler really delivers the hoped-for performance boost or only gives PHP code a boost in special cases remains to be seen in practice.

The Author

Tim Sch¸rmann is a freelance computer scientist and author. Besides books, Tim has published various articles in magazines and on websites.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Pandas: Data analysis with Python
    The Python Data Analysis Library, or Pandas, is built on top of the fast math library NumPy and makes analysis of large volumes of data an easy and efficient experience.
  • Modern Fortran – Part 2

    Fortran 90 was only the start. The next two iterations – 95 and 2003 – pulled Fortran into a new era of programming languages.

  • Data Analysis with Panda

    The Python Data Analysis Library, or Pandas, is built on top of the fast math library NumPy and makes analysis of large volumes of data an easy and efficient experience.

  • Innovations in PowerShell 5
    Windows 10 brings an updated, fifth release of PowerShell that vastly simplifies the task of managing modules and software packages. The scripting language now also handles various formatted output from commands and selection lists.
  • CoffeeScript: A Replacement for JavaScript?

    Through the years, many languages have tried to improve or even replace JavaScript, including CoffeeScript, which runs in all JavaScript Runtime Environments and compiles into JavaScript.

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=