What do strict types do in PHP?

后端 未结 3 619

I\'ve seen the following new line in PHP 7, but nobody really explains what it means. I\'ve googled it and all they talk about is will you be enabling it or not like a poll

3条回答
  •  一生所求
    2020-11-29 19:57

    Strict Types in PHP affect coercion types.

    By setting 'strict_types=1', you tell the engine that "int $x" means "$x must only be an int proper, no type coercion allowed". You have the great assurance you're getting exactly and only what was given, without any conversion or potential loss.

    All you need to know about strict types in PHP :)

    https://medium.com/@chemaclass/strict-types-in-php-d4166bd25394

提交回复
热议问题