Install via yarn add locutus and import:
import { set_time_limit } from 'locutus/php/info/set_time_limit'.
Or with CommonJS: const { set_time_limit } = require('locutus/php/info/set_time_limit')
Use a bundler that supports tree-shaking so you only ship the functions you actually use.
Vite,
webpack,
Rollup, and
Parcel
all handle this. For server-side use this is less of a concern.
Examples
These examples are extracted from test cases that automatically verify our functions against their native counterparts.
#
code
expected result
1
set_time_limit(4)
undefined
Dependencies
This function uses the following Locutus functions:
typePhpRuntimeBooleanKey = { [K in keyof PhpRuntimeKnownEntryMap]: PhpRuntimeKnownEntryMap[K] extendsboolean ? K : never }[keyof PhpRuntimeKnownEntryMap]
functiongetPhpRuntimeBoolean(key, fallback) { const value = getPhpRuntimeEntry(key) returntypeof value === 'boolean' ? value : fallback }
// php/info/set_time_limit (target function module) functionset_time_limit(seconds) { // discuss at: https://locutus.io/php/set_time_limit/ // original by: Brett Zamir (https://brett-zamir.me) // test: skip-all // example 1: set_time_limit(4) // returns 1: undefined
setTimeout(function () { if (!getPhpRuntimeBoolean('timeoutStatus', false)) { setPhpRuntimeEntry('timeoutStatus', true) } thrownewError('Maximum execution time exceeded') }, seconds * 1000) }
Improve this function
Locutus is a community effort following
The McDonald's Theory:
we ship first iterations, hoping others will improve them.
If you see something that could be better, we'd love your contribution.