strict

In ECMAScript5, what's the scope of “use strict”?

…衆ロ難τιáo~ 提交于 2019-12-17 15:46:52
问题 What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }()); But I'm not sure if that would break other code or not. I know that I can do this, which will scope the pragma to the function... (function () { "use strict"; // my stuff here... }()); but JSLint complains about it (when the "strict" JSLint option is enabled) because it thinks you're executing

Does strict mode prohibit statement level function declarations?

人盡茶涼 提交于 2019-12-17 13:53:22
问题 "use strict"; if (true) { function foo() { } } In PhpStorm this code shows an error: Function statement not at top level of a program or function is prohibited However, Chrome happily executes it, even in the debugger and without any console output. Now is it prohibited or not? 回答1: Yes, in ES5 they are prohibited (and in strict mode, all implementations throw). See also Kangax' great article for function statements in sloppy mode. However, in ES6 they are block-level function declarations

PHP 5 disable strict standards error

余生长醉 提交于 2019-12-16 23:34:07
问题 I need to setup my PHP script at the top to disable error reporting for strict standards. Can anybody help ? 回答1: Do you want to disable error reporting, or just prevent the user from seeing it? It’s usually a good idea to log errors, even on a production site. # in your PHP code: ini_set('display_errors', '0'); # don't show any errors... error_reporting(E_ALL | E_STRICT); # ...but do log them They will be logged to your standard system log, or use the error_log directive to specify exactly

Strict Standards: Non-static method (joomla and roksprocket)

我的梦境 提交于 2019-12-13 04:20:49
问题 Strict Standards: Non-static method K2ModelItemlist::getCategoryTree() should not be called statically, assuming $this from incompatible context in C:\xampp\htdocs\virgin\components\com_roksprocket\lib\RokSprocket\Provider\K2\Filter.php on line 151 All I have this error...I am using RokSprocket, Joomla and received the above error... It seems to have originated from protected function category($data) { if(file_exists(JPATH_SITE.'/components/com_k2/models/itemlist.php')) require_once (JPATH

How is JavaScript's strict mode implemented

一世执手 提交于 2019-12-12 06:29:12
问题 Update: Perhaps the way the function is called is to blame, so here's to it: 2 JS files Main.js: self invoking (non-strict) function that adds an event listener for the '(on)load' event. The callback calls a loader function, that parses the location.pathname, and calls an init function, and detaches/removes the '(on)load' listener & returns null (explicitly). PageSpecific.js: contains the _init function, adds a couple of event listeners to the body. One of these listeners' callback (also

Why does PHP assigns context to a static method call and does not give an E_STRICT notice?

大城市里の小女人 提交于 2019-12-12 01:43:30
问题 I ran into some very strange behaviour on PHP5.4 (also present in 5.5). Basically, I am calling a non-static method statically and I am not getting an E_STRICT error where I definitely should be getting one. <?php error_reporting(E_ALL); class A { public function iAmNotStatic() {} } Now, if I do this: A::iAmNotStatic(); Then I get the error as expected Strict standards: Non-static method A::iAmNotStatic() should not be called statically . And also, if I make the call from object context, I

Strict Standards: Only variables should be passed by reference in..

≡放荡痞女 提交于 2019-12-11 20:15:26
问题 I am receiving an error when I attempt to upload an image. The image is always uploaded, but after every upload I receive this error: Strict Standards: Only variables should be passed by reference in /filemanager/afmlib.php on line 57 Line 57 in my filemanager is: function AFM_fileExt($filename) { return strtolower(end(explode('.', $filename)));////THIS IS LINE: 57 } How can I fix this? 回答1: Why not let PHP do the work: function AFM_fileExt($filename) { return strtolower(pathinfo($filename,

PHP7 produce error when array push is used on a string

末鹿安然 提交于 2019-12-11 04:57:07
问题 How can I configure PHP 7 to produce an error when an item is pushed to a string, for example: $items = ''; $items[] = 'test'; Is this possible? 回答1: In PHP 5.6 and 7.0, it is valid to convert a variable containing an empty string into an array like this. Therefore, you will need to provide your own validation to produce an exception. function checkAndAssign($var, $val){ if (is_string($var)){ throw new ErrorException('Do not assign array item to a string'); } return $val; } $items = ''; try{

Multiple definitions of a property not allowed in strict mode - Angular

爷,独闯天下 提交于 2019-12-11 04:26:52
问题 I ran into this in my Angular (6) project in IE, which caused the app to not load. It only occurred in the prod build of the app, which is concatenated and minified by Angular. The local dev version running under 'ng serve' did not cause the issue. This error was in the Chrome dev console: SCRIPT1046: Multiple definitions of a property not allowed in strict mode File: main.51c74b0704ecaa189364.js, Line: 1, Column: 1263758 Here was the location in the minified main script it was referring to:

Inconsistent behaviour of “this” in JavaScript strict mode

微笑、不失礼 提交于 2019-12-11 03:28:07
问题 Update For clarity: @FelixKing: Yes, I expected this to still be undefined when calling window.foo() , and here's why: since, in JavaScript: function foo() { console.log('I am a function'); } Is ( almost ) the same thing as: var foo = function() { console.log('I am a function'); } and foo === window.foo evaluates to true, I'd expect them both to behave alike. If functions are variables, and JS falls back to the global object (inside function x, a variable isn't declared but you use it, JS