#49068 [NEW]: Associative array index doesn't produce a notice

2009-07-26 Thread simon+php at thulbourn dot com
From: simon+php at thulbourn dot com
Operating system: *
PHP version:  5.3.0
PHP Bug Type: Arrays related
Bug description:  Associative array index doesn't produce a notice

Description:

An array with no associative keys doesn't throw a notice or error when 
one is used as an associative keyed array.

Reproduce code:
---


Expected result:

Notice: Undefined index

Actual result:
--
fbb

-- 
Edit bug report at http://bugs.php.net/?id=49068&edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49068&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49068&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49068&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49068&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49068&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49068&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=49068&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=49068&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=49068&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=49068&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=49068&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=49068&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=49068&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49068&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=49068&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=49068&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=49068&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=49068&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=49068&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=49068&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=49068&r=mysqlcfg



#49068 [Bgs]: Using undefined assoc array index does not cause notice inside foreach

2009-07-27 Thread simon+php at thulbourn dot com
 ID:   49068
 User updated by:  simon+php at thulbourn dot com
 Reported By:  simon+php at thulbourn dot com
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6SVN (2009-07-26)
 New Comment:

I believe that it should issue a warning rather than converting to an 
integer.

It seems like a retarded action to convert the string to a 0, if I was

to use a numeric index that doesn't exist, I'd receive a notice. Some 
consistency would be nice.


Previous Comments:


[2009-07-26 23:07:46] ras...@php.net

That has nothing to do with a foreach.  The same effect can be seen
with:

$a = 'foo';
echo $a['bar'];

$a is a string which is essentially an array of characters with
numerical indices.  Given that, 'bar' is converted to an integer, so you
end up with $a[0] which does exist, so no warning.

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

[2009-07-26 22:09:07] simon+php at thulbourn dot com

Description:

An array with no associative keys doesn't throw a notice or error when

one is used as an associative keyed array.

Reproduce code:
---


Expected result:

Notice: Undefined index

Actual result:
--
fbb





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



#49068 [Bgs]: Using undefined assoc array index does not cause notice inside foreach

2009-07-27 Thread simon+php at thulbourn dot com
 ID:   49068
 User updated by:  simon+php at thulbourn dot com
 Reported By:  simon+php at thulbourn dot com
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6SVN (2009-07-26)
 New Comment:

Granted, I could have provided a better sample case so:

$a = array('foo');

// echo a index that doesn't exist
echo $a['bar'];

PHP should produce a notice claiming an undefined index 'bar', instead

it outputs the first char of the 0 index, in this case 'f', it's 
obviously converting the string to a 0 instead of producing the notice.


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

[2009-07-27 10:04:24] simon+php at thulbourn dot com

I believe that it should issue a warning rather than converting to an 
integer.

It seems like a retarded action to convert the string to a 0, if I was

to use a numeric index that doesn't exist, I'd receive a notice. Some 
consistency would be nice.)



[2009-07-26 23:07:46] ras...@php.net

That has nothing to do with a foreach.  The same effect can be seen
with:

$a = 'foo';
echo $a['bar'];

$a is a string which is essentially an array of characters with
numerical indices.  Given that, 'bar' is converted to an integer, so you
end up with $a[0] which does exist, so no warning.

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

[2009-07-26 22:09:07] simon+php at thulbourn dot com

Description:

An array with no associative keys doesn't throw a notice or error when

one is used as an associative keyed array.

Reproduce code:
---


Expected result:

Notice: Undefined index

Actual result:
--
fbb





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



#49068 [Bgs]: Using undefined assoc array index does not cause notice inside foreach

2009-07-27 Thread simon+php at thulbourn dot com
 ID:   49068
 User updated by:  simon+php at thulbourn dot com
 Reported By:  simon+php at thulbourn dot com
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6SVN (2009-07-26)
 New Comment:

Sorry, the new test code was wrong, here's one that proves my point

$blah = "foo";echo $blah["frog"];


Previous Comments:
----

[2009-07-27 10:20:06] simon+php at thulbourn dot com

Granted, I could have provided a better sample case so:

$a = array('foo');

// echo a index that doesn't exist
echo $a['bar'];

PHP should produce a notice claiming an undefined index 'bar', instead

it outputs the first char of the 0 index, in this case 'f', it's 
obviously converting the string to a 0 instead of producing the
notice.)

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

[2009-07-27 10:04:24] simon+php at thulbourn dot com

I believe that it should issue a warning rather than converting to an 
integer.

It seems like a retarded action to convert the string to a 0, if I was

to use a numeric index that doesn't exist, I'd receive a notice. Some 
consistency would be nice.)



[2009-07-26 23:07:46] ras...@php.net

That has nothing to do with a foreach.  The same effect can be seen
with:

$a = 'foo';
echo $a['bar'];

$a is a string which is essentially an array of characters with
numerical indices.  Given that, 'bar' is converted to an integer, so you
end up with $a[0] which does exist, so no warning.

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

[2009-07-26 22:09:07] simon+php at thulbourn dot com

Description:

An array with no associative keys doesn't throw a notice or error when

one is used as an associative keyed array.

Reproduce code:
---


Expected result:

Notice: Undefined index

Actual result:
--
fbb





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