10

As asked above, are we still required to put declare(strict_types=1) in the header of every single program in our projects in PHP 8.1?

I'd love for it to be just strict all the time.

Kladskull
  • 10,332
  • 20
  • 69
  • 111

1 Answers1

7

Yes! Tested with PHP 8.1.7 there is still a difference.

See this question to understand what the strict types do.

New in PHP 8.1: when a float value is coerced to an int value implicitly, like in the example from the other question, a deprecation notice is triggered: PHP Deprecated: Implicit conversion from float 1.4 to int loses precision. More details

Further reading

nickel715
  • 2,505
  • 1
  • 23
  • 28