When I set error_reporting(E_ALL | E_STRICT);, my code produces Undefined variable errors. I can solve them, but I am wondering whether there is any difference in speed or memory usage between writing code that passes strict checks, and just turning E_STRICT off?
When I set error_reporting(E_ALL | E_STRICT); , my code produces Undefined variable errors. I
Share
There is no mechanical benefit. You are, however, protected from doing really common, really dumb things like not always initializing a variable before using it – because with
E_STRICTon, PHP will generate an error instead of allowing functions to break in potentially-catastrophic, and probably-invisible ways.For example, it’s completely conceivable that a database-backed application uses a variable that isn’t initialized by all possible execution paths:
Eventually it doesn’t get initialized, and somebody’s medical records table is silently truncated.
In short, you should always develop with all warnings: it’s your first line of defense. When it comes time to move your code into production, though, you absolutely want error reporting off. You don’t want malicious users gaining insight into the inner workings of your application, or – worse – your database.