Browsing index pages (2 articles)
↧
Why does PHP strict typing allow function arguments of wrong type?
I'm using PHP 7.4.16. I enabled strict_types in my PHP file thinking it would prevent passing a string argument to a function expecting an int by throwing a TypeError. However, the function actually...
View ArticleAnswer by Alex Ruiz for Why does PHP strict typing allow function arguments...
strict_types only affects function calls within the file in which it's declared. From the PHP docs:Note:Strict typing applies to function calls made from within the file with strict typing enabled, not...
View Article
Browsing index pages (2 articles)