Php 类型前带询问点的变量声明

Php variable declaration with an interrogation point before the type

在 php 中,以下两个变量声明在过程模式和 class 内部有什么区别:

谢谢你的灯

变量$str只能是类型string:

string $str;

变量 $str 的类型可以是 stringnull:

?string $str;