ID:               45936
 User updated by:  php at bouchery dot com
 Reported By:      php at bouchery dot com
 Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: All
 PHP Version:      5.2.6
 New Comment:

To my point of view, "[]" is like an operator which mean "append the
array", but this variable is not declared.

In addition:
<?php
$x = 5;
$x[] = 7;
?>

This code will generate a "Warning: Cannot use a scalar value as an
array".

It's not possible to do that because the variable is not an array and
it show that the brackets are a kind of operator, not a simple
assignment.


Previous Comments:
------------------------------------------------------------------------

[2008-08-27 18:10:31] [EMAIL PROTECTED]

why?

You assign a new array (and its first value) to a variable. What's
wrong with that? 
If you see $array[] this as:
$array = array('string');
would you expect it to fire an E_NOTICE ?

no ?
then why would this do so, if it has 100% the same meaning.

------------------------------------------------------------------------

[2008-08-27 15:30:47] php at bouchery dot com

Description:
------------
When error_reporting is set to "E_ALL" and trying append an undeclared
array, PHP should generate a "NOTICE" error.

Reproduce code:
---------------
<?php
error_reporting(E_ALL);

$array[] = 'string';

?> 

Expected result:
----------------
Notice: Undefined variable: array in /var/www/script.php on line 4

Actual result:
--------------
no error.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45936&edit=1

Reply via email to