Is it possible to write strictly typed PHP code?

后端 未结 9 891
陌清茗
陌清茗 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:03

    Perhaps you should try this PHP extension https://github.com/krakjoe/strict. Support for the following types is introduced:

    • string
    • integer, int
    • float, double
    • boolean, bool
    • resource

提交回复
热议问题