PHP's is_null in TypeScript

✓ Verified: PHP 8.3
Examples tested against actual runtime. CI re-verifies continuously. Only documented examples are tested.

How to use

Install via yarn add locutus and import: import { is_null } from 'locutus/php/var/is_null'.

Or with CommonJS: const { is_null } = require('locutus/php/var/is_null')

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.

#codeexpected result
1is_null('23')false
2is_null(null)true

Here's what our current TypeScript equivalent to PHP's is_null looks like.

export function is_null(mixedVar: string | null): boolean {
// discuss at: https://locutus.io/php/is_null/
// parity verified: PHP 8.3
// original by: Kevin van Zonneveld (https://kvz.io)
// example 1: is_null('23')
// returns 1: false
// example 2: is_null(null)
// returns 2: true

return mixedVar === null
}

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.

View on GitHub · Edit on GitHub · View Raw


« More PHP var functions


Star