Home > Article > Backend Development > Do the scalar type and return type declarations added in php7 play any role?
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?
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)!