Home  >  Article  >  Backend Development  >  Do the scalar type and return type declarations added in php7 play any role?

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

PHP中文网
PHP中文网Original
2016-08-04 09:22:101355browse


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)!


Statement:
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