ID:               28476
 Updated by:       [EMAIL PROTECTED]
 Reported By:      nepto at platon dot sk
 Status:           Analyzed
 Bug Type:         Arrays related
 Operating System: Gentoo Linux
 PHP Version:      4.3.6
 New Comment:

Still opened? Wasn't this already fixed in some newer version?


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

[2004-05-21 21:00:44] [EMAIL PROTECTED]

Implicit array creation ONLY occurs if the target variable is either
(A) not set, or (B) empty.  In this case the target variable is already
set to a non-blank string so it qualifies neither of those criteria.

It seems to me like this should throw a notice since, as you state, the
results are very much unexpected.

===================================================================
RCS file: /repository/Zend/Attic/zend_execute.c,v
retrieving revision 1.316.2.34
diff -u -r1.316.2.34 zend_execute.c
--- Zend/zend_execute.c 1 Apr 2004 22:05:38 -0000       1.316.2.34
+++ Zend/zend_execute.c 21 May 2004 18:59:27 -0000
@@ -780,6 +780,9 @@
                                array_init(container);
                                break;
                }
+       } else if ((container->type == IS_STRING || container->type ==
IS_BOOL) &&
+                               (type == BP_VAR_RW || type ==
BP_VAR_W)) {
+               zend_error(E_NOTICE, "Implicit array creation failed:
Target variable contains non-empty string or boolean true value.");
        }

        switch (container->type) {



While this is considered, I'd suggest explicitly initializing your
arrays before pushing data onto them.

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

[2004-05-21 20:10:16] nepto at platon dot sk

Description:
------------
Transformation of string variable to array variable does not work as
expected when prticular assignment is used.

It can be also bug in the var_dump(), but I do not suppose this.

Reproduce code:
---------------
<?php

/*
 * string-to-array.php
 *
 * Developed by Ondrej Jombik <[EMAIL PROTECTED]>
 * Copyright (c) 2004 Platon SDG, http://platon.sk/
 * Licensed under terms of GNU General Public License.
 * All rights reserved.
 *
 * Changelog:
 * 2004-05-10 - created
 *
 */

/* $Platon$ */

$str = 'string';

$ar['key'] = $str;
var_dump($ar['key']); // string(6) "string"

$ar['key']['sub-key'] = $ar['key'];
var_dump($ar['key']); /*  string(6) "string"
                          but expected is:
                                array(1) {
                                      ["sub-key"]=>
                                            string(6) "string"
                                }
*/

$ar['key'] = array('sub-key' => $ar['key']);
var_dump($ar['key']); /* now OK:
                            array(1) {
                                  ["sub-key"]=>
                                        string(6) "string"
                            }
*/

/* Modeline for ViM {{{
 * vim: set ts=4:
 * vim600: fdm=marker fdl=0 fdc=0:
 * }}} */

?>

Expected result:
----------------
Written in the code.

Actual result:
--------------
Written in the code as well.


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


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

Reply via email to