rfc:null_coercion_consistency
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:null_coercion_consistency [2022/04/08 16:38] – craigfrancis | rfc:null_coercion_consistency [2022/04/09 08:49] – Add user-defined function example craigfrancis | ||
---|---|---|---|
Line 66: | Line 66: | ||
$o[] = htmlspecialchars(false); | $o[] = htmlspecialchars(false); | ||
$o[] = htmlspecialchars(NULL); | $o[] = htmlspecialchars(NULL); | ||
+ | </ | ||
+ | |||
+ | With user-defined functions, while this does not cause a backwards compatibility issue (details below), it still highlights the coercion inconstancy, | ||
+ | |||
+ | <code php> | ||
+ | function user_function(string $s, int $i, float $f, bool $b) { | ||
+ | var_dump($s, | ||
+ | echo " | ||
+ | } | ||
+ | |||
+ | user_function(' | ||
+ | // string(1) " | ||
+ | |||
+ | user_function(2, | ||
+ | // string(1) " | ||
+ | |||
+ | user_function(3.3, | ||
+ | // string(3) " | ||
+ | |||
+ | user_function(false, | ||
+ | // string(0) "" | ||
+ | |||
+ | user_function(NULL, | ||
+ | // Uncaught TypeError x4? | ||
</ | </ | ||
Line 95: | Line 119: | ||
$value = array_pop($empty_array); | $value = array_pop($empty_array); | ||
$value = mysqli_fetch_row($result); | $value = mysqli_fetch_row($result); | ||
- | $value = json_decode($json); | + | $value = json_decode($json); |
</ | </ | ||
Line 218: | Line 242: | ||
sed -i '' | sed -i '' | ||
./ | ./ | ||
+ | |||
./ | ./ | ||
. 1 / 1 (100%) | . 1 / 1 (100%) |
rfc/null_coercion_consistency.txt · Last modified: 2023/10/18 11:57 by craigfrancis