ID: 28476
User updated by: nepto at platon dot sk
Reported By: nepto at platon dot sk
-Status: Feedback
+Status: Open
Bug Type: Arrays related
Operating System: Gentoo Linux
PHP Version: 4.3.6
New Comment:
Still buggy:
[EMAIL PROTECTED] kill-php $ php string-to-array.php
string(6) "string"
string(6) "string"
array(1) {
["sub-key"]=>
string(6) "string"
}
[EMAIL PROTECTED] kill-php $ php -v
PHP 4.3.10 (cli) (built: Dec 16 2004 14:59:37)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
[EMAIL PROTECTED] kill-php $
Previous Comments:
------------------------------------------------------------------------
[2005-02-03 05:31:18] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2004-11-01 22:15:23] [EMAIL PROTECTED]
Still opened? Wasn't this already fixed in some newer version?
------------------------------------------------------------------------
[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