Paul Krill
Editor at Large

PHP updates DOM API

news
Nov 25, 20242 mins
PHPProgramming LanguagesWeb Development

New DOM API in PHP 8.4.1 brings standards-compliant support for parsing HTML5 documents and adds functions to make working with documents more convenient.

Developing programming and coding technologies. Website design. Programmer working in a software develop company office.
Credit: REDPIXEL.PL / Shutterstock

PHP 8.4.1, an update to the longstanding server-side web scripting language, has been released with features including an updated DOM API that makes it easier to work with HTML5 documents.

Accessible from php.net, PHP 8.4.1 was released November 21. The update also offers better performance, improved syntax, andย improved type safety, according to php.net.

The new DOM API, available within the Dom namespace, includes standards-compliant support for parsing HTML5 documents and fixes longstanding compliance bugs in the behavior of DOM functionality. It also adds functions to make it more convenient to work with documents. Using the new DOM API documents can be created using Dom\HTMLDocumentand Dom\XMLDocument classes.

Also in PHP 8.4.1, aย new BcMath\Number object enables object-oriented usage and standard mathematical operators when working with arbitrary precision numbers. The objects are immutable and implement the Stringable interface, enabling them to be used in string contexts like echo $num.

With PHP 8.4.1, the scope to write to a property now may be controlled independently from the scope to read the property, reducing the need for boilerplate getter methods to expose a propertyโ€™s value without allowing modification from the outside of a class. Also, property hooks now provide support for computed properties that can natively be understood by IDEs and static analysis tools, without needing to write docblock comments that might be out of sync.

Finally, new lazy objects also are featured in PHP 8.4.1. A lazy object is an object whose initialization is deferred until the state is observed or modified.

Predecessor PHP 8.3 arrived a year ago, bringing typing of class constants. It was followed by multiple point releases.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorldโ€™s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorldโ€™s audience of software developers and other information technology professionals. Paul has won a โ€œBest Technology News Coverageโ€ award from IDG.

More from this author