Using PHP... an example. This produces a warning - as expected - and $myVar
stays as bool(true).
$myVar = true;
$myVar[] = 'Hello'; // Warning: Cannot use a scalar value as an array
But this next example 'works', $myVar
is converted into an array with a single element 'Hello'.
$myVar = false;
$myVar[] = 'Hello'; // Converted into an array
Results in:
array(1) {
[0]=>
string(5) "Hello"
}
Yet both bool(true) and bool(false) are both scalar. So why the difference? What rule in PHP governs this behaviour? Or is it 'just the way it is'?!
I initially thought it might be to do with type casting rules, but both bool(true) and bool(false) behave the same in this respect.
Thanks.