#38974 [NEW]: array should throw warning

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #38974 [NEW]: array should throw warning

    From: hendlerman at yahoo dot com
    Operating system: windows XP
    PHP version: 5.1.6
    PHP Bug Type: Arrays related
    Bug description: array should throw warning

    Description:
    ------------
    The error is caused by a user error, but I believe PHP should be throwing
    an error. PHP is not strongly typed, but I thought you get a warning if
    you try to convert a string to an array.

    Sorry I am not in 5.1.6


    Reproduce code:
    ---------------
    /**
    * Output for me
    * PHP version 5.1.4
    * Array ( [name] => 2alue )
    *
    * */
    function array_bug()
    {
    echo "PHP version ". phpversion().'<br />';
    $test_array = array();

    $test_array['name'] = 'value';
    $test_array['name']['count'] = 2;

    print_r($test_array);
    }

    array_bug(); exit;

    Expected result:
    ----------------
    I would expect an error or warning

    Actual result:
    --------------
    Array ( [name] => 2alue )

    --
    Edit bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=38974&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=38974&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=38974&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=38974&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=38974&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=38974&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=38974&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=38974&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=38974&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=38974&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=38974&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=38974&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=38974&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=38974&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=38974&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=38974&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=38974&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=38974&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=38974&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=38974&r=mysqlcfg[/url]
    hendlerman at yahoo dot com Guest

  2. Similar Questions and Discussions

    1. #40793 [NEW]: xmlrpc_is_fault shows warning if parameter is not an array
      From: camka at email dot ee Operating system: windows PHP version: 5.2.1 PHP Bug Type: XMLRPC-EPI related Bug description: ...
    2. #40793 [Opn->Bgs]: xmlrpc_is_fault shows warning if parameter is not an array
      ID: 40793 Updated by: tony2001@php.net Reported By: camka at email dot ee -Status: Open +Status: ...
    3. #39915 [NEW]: Trying to access the index of an integer should throw a warning
      From: thuejk at gmail dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    4. #38974 [Opn->Bgs]: array should throw warning
      ID: 38974 Updated by: derick@php.net Reported By: hendlerman at yahoo dot com -Status: Open +Status: ...
    5. Warning: Cannot use a scalar value as an array in
      Hi all This has just started coming up on a site I run. I haven't changed anything, it just started happening. Unfortunately, it's an adult...
  3. #2

    Default #38974 [Bgs]: array should throw warning

    ID: 38974
    Updated by: [email]tony2001@php.net[/email]
    Reported By: hendlerman at yahoo dot com
    Status: Bogus
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].


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

    [2006-09-27 14:53:23] [email]derick@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    ..

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

    [2006-09-27 14:47:10] hendlerman at yahoo dot com

    Description:
    ------------
    The error is caused by a user error, but I believe PHP should be
    throwing an error. PHP is not strongly typed, but I thought you get a
    warning if you try to convert a string to an array.

    Sorry I am not in 5.1.6


    Reproduce code:
    ---------------
    /**
    * Output for me
    * PHP version 5.1.4
    * Array ( [name] => 2alue )
    *
    * */
    function array_bug()
    {
    echo "PHP version ". phpversion().'<br />';
    $test_array = array();

    $test_array['name'] = 'value';
    $test_array['name']['count'] = 2;

    print_r($test_array);
    }

    array_bug(); exit;

    Expected result:
    ----------------
    I would expect an error or warning

    Actual result:
    --------------
    Array ( [name] => 2alue )


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    tony2001@php.net Guest

  4. #3

    Default #38974 [Bgs]: array should throw warning

    ID: 38974
    User updated by: hendlerman at yahoo dot com
    Reported By: hendlerman at yahoo dot com
    Status: Bogus
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "


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

    [2006-09-27 14:54:23] [email]tony2001@php.net[/email]

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].

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

    [2006-09-27 14:53:23] [email]derick@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    ..

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

    [2006-09-27 14:47:10] hendlerman at yahoo dot com

    Description:
    ------------
    The error is caused by a user error, but I believe PHP should be
    throwing an error. PHP is not strongly typed, but I thought you get a
    warning if you try to convert a string to an array.

    Sorry I am not in 5.1.6


    Reproduce code:
    ---------------
    /**
    * Output for me
    * PHP version 5.1.4
    * Array ( [name] => 2alue )
    *
    * */
    function array_bug()
    {
    echo "PHP version ". phpversion().'<br />';
    $test_array = array();

    $test_array['name'] = 'value';
    $test_array['name']['count'] = 2;

    print_r($test_array);
    }

    array_bug(); exit;

    Expected result:
    ----------------
    I would expect an error or warning

    Actual result:
    --------------
    Array ( [name] => 2alue )


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    hendlerman at yahoo dot com Guest

  5. #4

    Default #38974 [Bgs->Opn]: String is not properly overwritten in

    ID: 38974
    User updated by: hendlerman at yahoo dot com
    -Summary: array should throw warning
    Reported By: hendlerman at yahoo dot com
    -Status: Bogus
    +Status: Open
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    Changing title and re-opening so it gets reviewed again.


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

    [2006-09-27 15:14:18] hendlerman at yahoo dot com

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "

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

    [2006-09-27 14:54:23] [email]tony2001@php.net[/email]

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].

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

    [2006-09-27 14:53:23] [email]derick@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    ..

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

    [2006-09-27 14:47:10] hendlerman at yahoo dot com

    Description:
    ------------
    The error is caused by a user error, but I believe PHP should be
    throwing an error. PHP is not strongly typed, but I thought you get a
    warning if you try to convert a string to an array.

    Sorry I am not in 5.1.6


    Reproduce code:
    ---------------
    /**
    * Output for me
    * PHP version 5.1.4
    * Array ( [name] => 2alue )
    *
    * */
    function array_bug()
    {
    echo "PHP version ". phpversion().'<br />';
    $test_array = array();

    $test_array['name'] = 'value';
    $test_array['name']['count'] = 2;

    print_r($test_array);
    }

    array_bug(); exit;

    Expected result:
    ----------------
    I would expect an error or warning

    Actual result:
    --------------
    Array ( [name] => 2alue )


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    hendlerman at yahoo dot com Guest

  6. #5

    Default #38974 [Opn]: String is not properly overwritten in Multi Dimensional Arrays

    ID: 38974
    User updated by: hendlerman at yahoo dot com
    -Summary: String is not properly overwritten in
    Reported By: hendlerman at yahoo dot com
    Status: Open
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    edit title


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

    [2006-09-27 15:32:43] hendlerman at yahoo dot com

    Changing title and re-opening so it gets reviewed again.

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

    [2006-09-27 15:14:18] hendlerman at yahoo dot com

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "

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

    [2006-09-27 14:54:23] [email]tony2001@php.net[/email]

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].

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

    [2006-09-27 14:53:23] [email]derick@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    ..

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

    [2006-09-27 14:47:10] hendlerman at yahoo dot com

    Description:
    ------------
    The error is caused by a user error, but I believe PHP should be
    throwing an error. PHP is not strongly typed, but I thought you get a
    warning if you try to convert a string to an array.

    Sorry I am not in 5.1.6


    Reproduce code:
    ---------------
    /**
    * Output for me
    * PHP version 5.1.4
    * Array ( [name] => 2alue )
    *
    * */
    function array_bug()
    {
    echo "PHP version ". phpversion().'<br />';
    $test_array = array();

    $test_array['name'] = 'value';
    $test_array['name']['count'] = 2;

    print_r($test_array);
    }

    array_bug(); exit;

    Expected result:
    ----------------
    I would expect an error or warning

    Actual result:
    --------------
    Array ( [name] => 2alue )


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    hendlerman at yahoo dot com Guest

  7. #6

    Default #38974 [Opn->Bgs]: String is not properly overwritten in

    ID: 38974
    Updated by: [email]tony2001@php.net[/email]
    -Summary: String is not properly overwritten in Multi
    Dimensional Arrays
    Reported By: hendlerman at yahoo dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    # php -r '$s = "string"; $s[0] = 3; var_dump($s);'
    string(6) "3tring"

    This is expected behaviour.



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

    [2006-09-27 15:34:04] hendlerman at yahoo dot com

    edit title

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

    [2006-09-27 15:32:43] hendlerman at yahoo dot com

    Changing title and re-opening so it gets reviewed again.

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

    [2006-09-27 15:14:18] hendlerman at yahoo dot com

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "

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

    [2006-09-27 14:54:23] [email]tony2001@php.net[/email]

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].

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

    [2006-09-27 14:53:23] [email]derick@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    ..

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

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/38974[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    tony2001@php.net Guest

  8. #7

    Default #38974 [Bgs->Opn]: String is not properly overwritten in

    ID: 38974
    User updated by: hendlerman at yahoo dot com
    Reported By: hendlerman at yahoo dot com
    -Status: Bogus
    +Status: Open
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    the code you've outlined is not the same as the code I have.

    what happens to the key in the array called "count"?


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

    [2006-09-27 15:34:44] [email]tony2001@php.net[/email]

    # php -r '$s = "string"; $s[0] = 3; var_dump($s);'
    string(6) "3tring"

    This is expected behaviour.


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

    [2006-09-27 15:34:04] hendlerman at yahoo dot com

    edit title

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

    [2006-09-27 15:32:43] hendlerman at yahoo dot com

    Changing title and re-opening so it gets reviewed again.

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

    [2006-09-27 15:14:18] hendlerman at yahoo dot com

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "

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

    [2006-09-27 14:54:23] [email]tony2001@php.net[/email]

    $string[0] = 'c'; is perfectly valid code and that's what you get with
    $string['otherstring'].

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

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/38974[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    hendlerman at yahoo dot com Guest

  9. #8

    Default #38974 [Opn->Bgs]: String is not properly overwritten in

    ID: 38974
    Updated by: [email]tony2001@php.net[/email]
    Reported By: hendlerman at yahoo dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    It's autoconverted to integer, i.e. 0.


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

    [2006-09-27 15:37:37] hendlerman at yahoo dot com

    the code you've outlined is not the same as the code I have.

    what happens to the key in the array called "count"?

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

    [2006-09-27 15:34:44] [email]tony2001@php.net[/email]

    # php -r '$s = "string"; $s[0] = 3; var_dump($s);'
    string(6) "3tring"

    This is expected behaviour.


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

    [2006-09-27 15:34:04] hendlerman at yahoo dot com

    edit title

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

    [2006-09-27 15:32:43] hendlerman at yahoo dot com

    Changing title and re-opening so it gets reviewed again.

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

    [2006-09-27 15:14:18] hendlerman at yahoo dot com

    I understand that it's valid in PHP to overwrite the string with an
    array. The problem is that the string is not actually overwritten by
    the array. I thought that was clear from the sample code!

    Doesn't seem like a feature if the array isn't overwritten. Perhaps I
    should have titled = "String is not properly overwritten "

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

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/38974[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    tony2001@php.net Guest

  10. #9

    Default #38974 [Bgs]: String is not properly overwritten in

    ID: 38974
    User updated by: hendlerman at yahoo dot com
    Reported By: hendlerman at yahoo dot com
    Status: Bogus
    Bug Type: Arrays related
    Operating System: windows XP
    PHP Version: 5.1.6
    New Comment:

    OK.

    I can see how this is not a "bug" and expected.
    But I think the behaviour should be different. Maybe just:

    1. don't loose keys

    I can't post to php-dev ATM, but is that the proper place to have this
    discussion?


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

    [2006-09-27 15:45:14] [email]tony2001@php.net[/email]

    It's autoconverted to integer, i.e. 0.

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

    [2006-09-27 15:37:37] hendlerman at yahoo dot com

    the code you've outlined is not the same as the code I have.

    what happens to the key in the array called "count"?

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

    [2006-09-27 15:34:44] [email]tony2001@php.net[/email]

    # php -r '$s = "string"; $s[0] = 3; var_dump($s);'
    string(6) "3tring"

    This is expected behaviour.


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

    [2006-09-27 15:34:04] hendlerman at yahoo dot com

    edit title

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

    [2006-09-27 15:32:43] hendlerman at yahoo dot com

    Changing title and re-opening so it gets reviewed again.

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

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/38974[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=38974&edit=1[/url]
    hendlerman at yahoo dot com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139