Expand description
PHP value semantics the WordPress ports lean on: empty(), array reads and writes, array_merge(), integer
keys, the (array) and (string) casts and PHP 8’s loose ==.
Functions§
- array_
merge array_merge( $base, $over ): string keys of$overreplace in place or append; int keys are renumbered from 0 across both arrays.- bytes_
truthy - PHP truth of a byte string:
""and"0"are false, every other string is true. - get
$array['name']for a string key.- is_
empty - PHP’s
empty(): null, false, 0, 0.0,"","0"andarray()are empty. - is_
integer_ key - Whether PHP turns this string array key into an int key (
"10"becomes10;"010","-0"and"1e3"stay). - isset
isset( $array['name'] ): present and not null.- key_
to_ string - An array key as text: an int in decimal, a string as it is (lossily, when it is not UTF-8).
- loose_
eq - PHP 8’s
$a == $b. - set
$array['name'] = $value: replaces in place, or appends.- to_
array (array) $value: an array as it is, an object’s properties (integer-like names as int keys), an enum as itsnamealone (novalue, even for a backed enum:PhpValue::Enumcarries no value), null asarray(), and any other value asarray( 0 => $value ).- to_
array_ key $array[ $value ]’s key: null is"", a bool0or1, a float truncated toward zero (a finite float outside the int range wraps modulo 2^64, as PHP 8.5’szend_dval_to_lval()does:1e20is7766279631452241920,2^63isi64::MIN; NaN and infinities are0), an integer-like string an int;Nonefor an array or object, where PHP throws “Illegal offset type”.- to_
php_ int (int) $value(PHP 8.5, 64-bit): null and false 0, true 1; arrays 0 when empty, else 1; objects 1. APhpValue::Refis an unresolved back-reference and reads as null, 0; an object reference is 1.- to_
php_ string (string) $value: null and false"", true"1", ints in decimal, floats as PHP 8 prints them (precision14), arrays"Array". Objects have no__toString()here; they print their class name.- unset
unset( $array['name'] ): drops every entry with that string key.