How to Turn On Strict Types in PHP with declare(strict_types=1)
· 4 min read
By default, PHP converts a value to the type a function asks for when it can: pass the string "21" where an int is expected and PHP quietly makes it 21. One line at the top of a file, declare(strict_types=1);, turns that off, so a wrong type stops the call with an error.
