Introducing new features from php7.3 to php7.4

coldplay.xixi
Release: 2023-02-17 21:28:01
forward
3098 people have browsed it

Introducing new features from php7.3 to php7.4

1. Object attributes now support type declaration

Copy after login

In the above example, $id will be forced to be converted to integer type,$nameis String type

Recommended (free):PHP7

2. Arrow function

Now the arrow function will Provide a short syntax for defining functions whose value declarations are unclear within the scope

 $n * $factor, [1, 2, 3, 4]); // $nums = array(10, 20, 30, 40); ?>
Copy after login

3, limited return type covariance and parameter type covariance (Google Translate)

The following code will Will run

Copy after login

Full diff support is only provided when using autoloading. Within a single file, only non-cyclic type references can be used because all classes must be available before being referenced

4, Null merge assignment operator

Copy after login

5, Unpacking inside arrays (Google The translation is to unpack inside the array. See if this is wrong, use English first)

Copy after login

6. Numeric character separator

Numeric characters can include underscores between numbers.

Copy after login

7. Weak references

Weak references allow the programmer to retain a reference to an object that cannot be prevented from being destroyed does not prevent the object from being destroyed.)

8. Allow exceptions__toString()

can now be thrown through__toString()Exceptions, which in previous versions would have resulted in a fatal error, existing string conversions that could have resulted in a fatal error have been converted to throw exceptions.

We will look at the rest of the expansion later

The above is the detailed content of Introducing new features from php7.3 to php7.4. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!