<?php
$str = 'A';
$str[] = 'b';
?>
PHP Fatal error:  [] operator not supported for strings in - on line 3
-(3) : Fatal error - [] operator not supported for strings


<?php
$int = 123;
$int[] = 'b';
var_dump($int);
?>

PHP Warning:  Cannot use a scalar value as an array in - on line 3
-(3) : Warning - Cannot use a scalar value as an array

Warning: Cannot use a scalar value as an array in - on line 3
int(123)


We should raise fatal error for scalar, or raise warning
for string.

BTW, my preference is reinitialize var as array and assign
new element, raise notice error for this, though.
This would be a reasonable behavior for loosely typed
language to me.

--
Yasuo Ohgaki



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to