Skip to main content

Module value

Module value 

Source
Expand description

PHP value semantics (type juggling) on top of serde_json::Value.

Request parameters reach PHP code as PHP values. These functions answer the questions libraries ask about them (is_numeric, truthiness, string casts, ==) the way the engine does.

Enums§

Number
A PHP number after $value + 0.

Functions§

array_len
Number of elements of a PHP array value.
array_values
Iterates the elements of a PHP array value (list or map) in order.
compare_numbers
PHP 8 <=> for two numbers.
empty
PHP empty($value).
is_object
An empty JSON object: a stdClass instance in PHP.
json_number
A JSON number as PHP sees it: integers beyond i64 are floats.
le_numbers
PHP 8 $a <= $b for two numbers (zend_is_smaller_or_equal): integers compare exactly; otherwise both are floats, ZEND_THREEWAY_COMPARE is not below zero for NAN, so any comparison with NAN is false.
loose_eq
PHP 8 loose equality ($a == $b).
loose_str_eq
PHP $a == $b for two strings (zendi_smart_str_equals): two numeric strings compare as numbers, anything else byte for byte. Numeric strings are ASCII, so a string that is not UTF-8 only equals itself.
numeric
PHP is_numeric($v) ? $v + 0 : null.
numeric_bytes_ex
numeric_str_ex on bytes (a numeric string is ASCII, so bytes that are not UTF-8 are never numeric).
numeric_str
PHP numeric-string parsing (is_numeric + + 0).
numeric_str_ex
Like numeric_str, also reporting integer overflow as the engine’s is_numeric_string_ex does: 1 or -1 when an integer-looking string did not fit in i64 and became a float.
to_string
PHP (string) $value for scalars; None for arrays and objects.
truthy
PHP truthiness ((bool) $value).