4 ms·
"use strict"; (note 'use' is part of a string) should work in PHP for the same reason it does in ECMAScript -- it is a no-op at the language level (creating a
by scintill76 12y ago
"use strict";
(note 'use' is part of a string) should work in PHP for the same reason it does in ECMAScript -- it is a no-op at the language level (creating a string literal and doing nothing with it), that is unlikely to appear in old code, and can be given new meaning in the next-level language spec.
- chx 12y agoMaybe. But it means the parser now needs to "make sense" of strings whereas before it was just skipping over them.
- function_seven 12y agoNo it doesn't. The "use strict" declaration must occur before any other statements, allowing the parser to look specifically for those bytes, and treat it as a separate token instead of as a string. It doesn't have to inspect the contents of all strings.