扫码阅读
手机扫码阅读

PHP8正式版发布,带来了注解和JIT

457 2024-01-25

我们非常重视原创文章,为尊重知识产权并避免潜在的版权问题,我们在此提供文章的摘要供您初步了解。如果您想要查阅更为详尽的内容,访问作者的公众号页面获取完整文章。

查看原文:PHP8正式版发布,带来了注解和JIT
文章来源:
鲁飞
扫码关注公众号
PHP 8 Release Summary

PHP 8 Release Summary

PHP 8 has been officially released, introducing significant changes, numerous new features, performance optimizations, such as named arguments, union types, attributes, constructor property promotion, match expressions, nullsafe operator, JIT, as well as improvements to the type system, error handling, and consistency.

Key Features and Improvements

  • Named Arguments: Allow skipping optional parameters and are order-independent, which makes the code more readable.
  • Attributes (Annotations): The new syntax does not affect lower versions since # is a comment symbol in PHP.
  • Constructor Property Promotion: Reduces boilerplate code by allowing properties to be defined in the constructor.
  • Union Types: Support for declaring more than one type, leading to better type checking.
  • Match Expression: A more powerful and concise alternative to the switch statement which performs strict comparisons.
  • Nullsafe Operator: Simplifies the syntax for null checks within method call chains, making the code cleaner.
  • Saner String to Number Comparisons: Numbers are now compared as numbers rather than strings when dealing with numeric strings.
  • Consistent Type Errors for Internal Functions: Most internal functions now throw an error exception if parameter validation fails.

JIT Compilation Engine

PHP 8 introduces two JIT compilation engines, with the tracing JIT showing the most promise by improving performance up to three times in synthetic benchmarks and 1.5 to 2 times in some long-running applications.

Additional Enhancements

Other improvements include enhancements to the type system and error handling, syntax adjustments, new classes, interfaces, and functions. Opaque objects replace resource types for Curl, Gd, Sockets, OpenSSL, XMLWriter, and XML extensions.

More detailed information about the new features and functionalities can be found on the official PHP website. Interested readers can also refer to Nikic's PPT shared at a previous PHPCon for an in-depth look at PHP 8's features.

Follow the QR code for more updates and press "Like" before you leave!

想要了解更多内容?

查看原文:PHP8正式版发布,带来了注解和JIT
文章来源:
鲁飞
扫码关注公众号