Do the scalar type and return type declarations added in php7 play any role?

PHP中文网
Release: 2016-08-04 09:22:10
Original
1356 people have browsed it


Scalar type and return type declarations have been added to php7.

I checked the information and found that it doesn’t seem to improve efficiency much.

So what exactly does this scalar type and return type declaration do?

Reply content:

Scalar type and return type declarations have been added to php7.

I checked the data and found that it doesn’t seem to improve efficiency much.

So what exactly does this scalar type and return type declaration do?


This function was originally designed to optimize JIT compilation, but later JIT was not introduced into PHP7, but strong typing remained. In PHP, theoretically speaking, strong typing will bring performance losses. In addition, strong typing can currently be used for type detection and forced type conversion.


I continued to research and found that the effect is to limit the return type. When the inherited object re-overrides the method, it can ensure that the return is uniform and will not cause calling problems.

The above are the scalar type and return type declarations added in php7. Do they have any effect? For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template