Is it possible to write strictly typed PHP code?

后端 未结 9 881
陌清茗
陌清茗 2020-12-14 15:34

For example, is it possible to write code like this:

int $x = 6;
str $y = \"hello world\";
bool $z = false;
MyObject $foo = new MyObject();

9条回答
  •  我在风中等你
    2020-12-14 16:04

    PHP is not strictly typed, so no. That said, it does support limited type hinting on functions - that's as close as it gets.

提交回复
热议问题