#31303 [Opn->Csd]: treating a string like a regular array leads to a fatal offset

From: Date: Mon, 11 Apr 2005 07:51:27 +0000
Subject: #31303 [Opn->Csd]: treating a string like a regular array leads to a fatal offset
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969367772@lists.php.net to get a copy of this message
ID: 31303 Updated by: philip@php.net Reported By: schmad at miller-group dot net -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Mac OS X 10.3.7 PHP Version: 5.0.3 New Comment: This behavior isn't limited to [] either, {} is affected the same way. But anyway, using unset() on strings like this has no use whatsoever. An example has now been added to migration5.xml so this bug is closed. Previous Comments: ------------------------------------------------------------------------ [2004-12-30 09:48:41] vrana@php.net Reverted, sorry. I'm not sure where to add this piece of information so I'm leaving this bug open for someone else :-). ------------------------------------------------------------------------ [2004-12-29 20:47:41] nlopess@php.net Yep, please revert the change at 'language.types.string'. PHP 5 only causes a fatal error whith 'unset($string["a"]);' Nuno ------------------------------------------------------------------------ [2004-12-29 17:08:00] et@php.net You changed the wrong thing, $string[0] still works. et@edea:~$ php -r '$foo = "abc"; var_dump($foo[0]);' string(1) "a" Also, the second example doesn't seem to produce a fatal error. et@edea:~$ php -r '$link = ""; var_dump(count($link["two"]));' Notice: Uninitialized string offset: 0 in Command line code on line 1 int(1) et@edea:~$ php -v PHP 5.1.0-dev (cli) (built: Dec 28 2004 20:03:13) ------------------------------------------------------------------------ [2004-12-29 16:43:35] vrana@php.net This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. I believe it is already documented in Backward Incompatible Changes under Migrating from PHP 4 to PHP 5 in the sentence "Illegal use of string offsets causes E_ERROR instead of E_WARNING." However, I have added this to the String Type chapter: "However, this syntax is deprecated as of PHP 4 and produces fatal error in PHP 5." ------------------------------------------------------------------------ [2004-12-26 22:29:16] nlopess@php.net opening.. ------------------------------------------------------------------------ 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 http://bugs.php.net/31303 -- Edit this bug report at http://bugs.php.net/?id=31303&edit=1

« previous php.doc (#969367772) next »