Documentation
¶
Overview ¶
Package phpval holds PHP's value semantics: how a value converts to a string, an integer or a truth value, how a collection reads back as a list of values or strings, and how two values order under PHP 8's <=> operator.
It exists so the files under stdlib/core can each register their own area without importing one another. Every one of them coerces its arguments, and the coercion has to have exactly one definition: sort() and in_array() disagreeing about what "10" is would be a bug no test names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare is PHP 8's comparison operator (<=>), which sort() and rsort() order by. Its rules, in the order they are applied:
arrays the shorter array is smaller, an array beats any scalar
null vs string the null becomes "" and the two compare as strings
bool or null both sides are cast to bool
numbers two numbers, or a number and a numeric string, or two
numeric strings, compare numerically, so "9" is less than
"10", and a list of digits out of explode() sorts the way
the same list sorts in PHP
anything else both sides are cast to string and compared bytewise, which
is where a number meeting a non-numeric string ends up
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.