Oihana PHP

getJsonType.php

Table of Contents

Functions

getJsonType()  : string
Get JSON type of a PHP value.

Functions

getJsonType()

Get JSON type of a PHP value.

getJsonType(mixed $value[, string $default = 'unknown' ]) : string
Parameters
$value : mixed

The value to evaluates.

$default : string = 'unknown'

The default return value if the type is not a valid JSON type.

Tags
example
use function oihana\core\json\getJsonType;

echo getJsonType( [ 1, 2 ] ) ; // 'array'
echo getJsonType( 'x' ) ;      // 'string'
echo getJsonType( null ) ;     // 'null'
author

Marc Alcaraz (ekameleon)

since
1.0.7
Return values
string

One of 'null', 'boolean', 'integer', 'number', 'string', 'array', 'object', or $default.

On this page

Search results