Does PHP 8.0 have new features?
PHP 8.0 is a big update of the PHP language. It contains several features and new optimization including JIT, named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator và improvements in the type system, error handling, and consistency.
JIT (Just in Time)
JIT is updated better and PHP 8.0 illustrates 2 JIT compilation engines.
And Trancing JIT, the most promising of the two, shows about 3 times better performance on synthetic benchmarks and 1.5–2 times improvement on some specific long-running applications. Typical application performance is on par with PHP 7.4.
- Specify only required parameters, skipping optional ones.
- Arguments are order-independent and self-documented.
Instead of PHPDoc annotation, you can now use structured metadata with PHP's native syntax.
Constructor property promotion
Less boilerplate code to define and initialize properties.
Instead of PHPDoc annotation for combination type, you can use native union type declarations that are validated at runtime.
The new match is similar to switch and has those features:
- Match is an expression, meaning its result can be stored in a variable or returned.
- Match branches only support single-line expressions and do not need a break; statement.
- Match does strict comparisons.
Instead of null check conditions, now you can use a chain of calls with new nullsafe operators. When the evaluation of one component in the chain fails, the execution of the entire chain aborts and the entire chain evaluates to null.
Consistent type errors for internal functions
Most of the internal functions now throw an Error exception if the validation of parameters fails
We “Hachinet Software” are Vietnam based software service and talented provider. We specialize in the followings:
1. Web application (.NET, JAVA, PHP, etc)
2. Framework (ASP, MVC, AngularJS, Angular6, Node JS, Vue JS)
3. Mobile application: IOS (Swift, Object C), Android (Kotlin, Android)
4. System applications (Cobol, ERP, etc),
5. New Technology (Blockchain, etc).
If you are interested in our service or looking for an IT outsourcing partner in Vietnam, do not hesitate to contact us at email@example.com.