strict

Blank page if I declare(strict_types=1); in PHP 7 at top of the file

主宰稳场 提交于 2019-11-30 13:27:53
Recently I was checking out on PHP 7, specifically return type declaration and type hinting . I have compiled PHP 7 from source(master branch from Github ) and running it in Ubuntu 14.04 virtual box. I tried to run following code to get a test of new Exceptions . But it Gave a blank page. <?php function test(): string { return []; } echo test(); Then I realize I have to set error to be displayed on screen. So I added old fashioned ini_set('display_errors', 1); like below, <?php ini_set('display_errors', 1); function test(): string { return []; } echo test(); that gave me following TypeError as

Which (javascript) environments support ECMAscript 5 strict mode? (aka “use strict”)

▼魔方 西西 提交于 2019-11-30 10:56:35
问题 ECMAScript 5 is in its final draft as I write this; It is due to include a strict mode which will prevent you from assigning to the global object, using eval, and other restrictions. (John Resig's Article is a good introduction.) This magical sanity-saving mode is triggered by including the string "use strict" at the top of your file (or function.) However, in older environments, "use strict" is a no-op. If you add "use strict" and don't test it in a strict environment, you could be leaving a

the seq function and strictness

ぃ、小莉子 提交于 2019-11-29 22:10:25
I have been wondering about this a lot, but I haven't been able to find anything about it. When using the seq function, how does it then really work? Everywhere, it is just explained saying that seq a b evaluates a , discards the result and returns b . But what does that really mean? Would the following result in strict evaluation: foo s t = seq q (bar q t) where q = s*t What I mean is, is q strictly evaluated before being used in bar ? And would the following be equivalent: foo s t = seq (s*t) (bar (s*t) t) I find it a little hard getting specifics on the functionality of this function. You

Blank page if I declare(strict_types=1); in PHP 7 at top of the file

倖福魔咒の 提交于 2019-11-29 19:05:16
问题 Recently I was checking out on PHP 7, specifically return type declaration and type hinting. I have compiled PHP 7 from source(master branch from Github) and running it in Ubuntu 14.04 virtual box. I tried to run following code to get a test of new Exceptions. But it Gave a blank page. <?php function test(): string { return []; } echo test(); Then I realize I have to set error to be displayed on screen. So I added old fashioned ini_set('display_errors', 1); like below, <?php ini_set('display

How do I average column values from a tab-separated data file, ignoring a header row and the left column?

不羁的心 提交于 2019-11-29 15:18:54
My task is to compute averages from the following data file, titled Lab1_table.txt : retrovirus genome gag pol env HIV-1 9181 1503 3006 2571 FIV 9474 1353 2993 2571 KoRV 8431 1566 3384 1980 GaLV 8088 1563 3498 2058 PERV 8072 1560 3621 1532 I have to write a script that will open and read this file, read each line by splitting the contents into an array and computer the average of the numerical values ( genome , gag , pol , env ), and write to a new file the average from each of the aforementioned columns. I've been trying my best to figure out how to not take into account the first row, or the

“use strict”; now allows duplicated properties?

丶灬走出姿态 提交于 2019-11-29 10:20:14
I just found that in the last Chrome 42 and FF 37.0.2 this lines of code are perfectly legal "use strict"; var o = { p: 1, p: 2 }; (copy-pasted from MDN ) In IE 10-11 and Opera 28.0.1750 it throws error as expected. In the same time, abc=0; causes error (undeclared variable) as expected. Does anybody know what caused such change? There is a Bugzilla ticket here. From what I gather (here and other pages I have looked up), duplicate properties are legal in ECMAScript version 6, opposed to ES5, where it is forbidden in strict mode. 来源: https://stackoverflow.com/questions/29936845/use-strict-now

Disable a built-in function in javascript (alert)

余生长醉 提交于 2019-11-29 08:07:36
Simple: I want to disable/overwrite alert() . Can I do this? More importantly, is it right to do this? What about strict mode? Yes, you can disable or overwrite alert() . No, it's not right to do it, except in some bizarre and limited situations. Disable: window.alert = function() { }; Override: window.alert = function(text) { /* do something */ }; Yes you can, it's your choice. You could also store the original 'alert': window.nativeAlert = window.alert; window.alert = function(val){console.log(val+' (alert disabled)');}; now the old alert is still usable: nativeAlert('something'); 来源: https:

Get current function name in strict mode

半世苍凉 提交于 2019-11-29 01:30:22
I need the current function name as a string to log to our log facility. But arguments.callee.name only works in loose mode. How to get the function name under "use strict" ? For logging/debugging purposes, you can create a new Error object in the logger and inspect its .stack property, e.g. function logIt(message) { var stack = new Error().stack, caller = stack.split('\n')[2].trim(); console.log(caller + ":" + message); } function a(b) { b() } a(function xyz() { logIt('hello'); }); You can bind function as its context then you can access its name via this.name property: function x(){ console

How to turn off MySQL strict mode in Rails

孤街醉人 提交于 2019-11-28 21:16:16
Upgrading to Rails 4, it seems MySQL strict mode is now on by default for Rails connections. I say this because my Rails app is getting "Mysql2::Error: Data too long for column" when saving a string value longer than 255 characters. Yet, I paste the same query into MySQL console (where global strict mode is reported to be off) and it works fine, just with truncation warnings. As further evidence, it says here "Rails 4 both use strict mode by default". My question is how can I turn strict mode off from the Rails app? I'd rather avoid upgrading everything to support it right now. You can set

Would this enable “use strict” globally?

偶尔善良 提交于 2019-11-28 20:17:35
Similar, but not the same as, How to enable ECMAScript "use strict" globally? I have bought JavaScript Patterns and it recommends enabling use strict. Adding it to the two dozen javascript files would be a bit of a chore, so enabling it globally would be nice. I originally thought about adding to the top of my main.js like this: "use strict" require({ priority: ["jquery", "raphael", "myapp"] }); However I then thought that it maybe would only enable it for that file. I then thought about this: <script data-main="lib/main" src="lib/require.js">"use strict"</script> Would either of these enable