UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

64 lines (52 loc) 1.9 kB
--- layout: page title: "JavaScript set_time_limit function" comments: true sharing: true footer: true alias: - /functions/view/set_time_limit:786 - /functions/view/set_time_limit - /functions/view/786 - /functions/set_time_limit:786 - /functions/786 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's set_time_limit {% codeblock info/set_time_limit.js lang:js https://raw.github.com/kvz/phpjs/master/functions/info/set_time_limit.js raw on github %} function set_time_limit (seconds) { // From: http://phpjs.org/functions // + original by: Brett Zamir (http://brett-zamir.me) // * test: skip // * example 1: set_time_limit(4); // * returns 1: undefined // BEGIN REDUNDANT this.php_js = this.php_js || {}; // END REDUNDANT this.window.setTimeout(function () { if (!this.php_js.timeoutStatus) { this.php_js.timeoutStatus = true; } throw 'Maximum execution time exceeded'; }, seconds * 1000); } {% endcodeblock %} - [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/info/set_time_limit.js) Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are the closest match to this hashtable-like data structure. Please also note that php.js offers community built functions and goes by the [McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just: - [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/info/set_time_limit.js) ### Example 1 This code {% codeblock lang:js example %} set_time_limit(4); {% endcodeblock %} Should return {% codeblock lang:js returns %} undefined {% endcodeblock %} ### Other PHP functions in the info extension {% render_partial _includes/custom/info.html %}