Install via yarn add locutus and import:
import { is_object } from 'locutus/php/var/is_object'.
Or with CommonJS: const { is_object } = require('locutus/php/var/is_object')
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
is_object('23')
false
2
is_object({foo: 'bar'})
true
3
is_object(null)
false
Dependencies
This function uses the following Locutus functions:
// php/var/is_object (target function module) functionis_object(mixedVar) { // discuss at: https://locutus.io/php/is_object/ // original by: Kevin van Zonneveld (https://kvz.io) // improved by: Legaev Andrey // improved by: Michael White (https://getsprink.com) // example 1: is_object('23') // returns 1: false // example 2: is_object({foo: 'bar'}) // returns 2: true // example 3: is_object(null) // returns 3: false
returnisPhpAssocObject(mixedVar) }
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.