Ask a Question related to PHP Development, Design and Development.
-
php at pleaseletusknow dot com #1
#14066 [Com]: Can't suppress warnigns on accessing invalid string offset
ID: 14066
Comment by: php at pleaseletusknow dot com
Reported By: mfischer at guru dot josefine dot at
Status: Wont fix
Bug Type: Scripting Engine problem
Operating System: Any
PHP Version: 4.0CVS-2001-11-15
New Comment:
This error, in latest PHP versions, only occurs when your trying to
treat a plain variable as an array.
In most occasions you can get round this by adding in an isArray check
before you try to use the var as an array.
For example;
Problem:
if (isset($parameter['align'])) { echo 'moo'; } // error: Uninitialized
string offset
Solution:
if (!isarray($parameter)) { $parameter = array(); }
if (isset($parameter['align'])) { echo 'moo'; }
So your basically setting an empty array in place of an empty variable.
Previous Comments:
------------------------------------------------------------------------
[2003-04-25 11:07:59] [email]sniper@php.net[/email]
Since we now have this 'wont fix' status, let's use it. :)
------------------------------------------------------------------------
[2002-03-03 17:47:39] [email]derick@php.net[/email]
It's an engine thing, and can really not be fixed. The accessing of the
{3} is done after the END_SILENCE op at the CONCAT op.
I'll mark it as suspended for now.
------------------------------------------------------------------------
[2002-03-03 17:35:33] [email]mfischer@php.net[/email]
I'm not satisfied with this answer :-)
Why does it work with arrays but not with strings (and, bert, yeah I
know they aren't the same).
Just because "it's strings here" doesn't legitimate that a warnings is
thrown. Using your suggestion is rather cumbersome.
Is it an implemention issue? Can it be solve to be less long winded?
"it is"
a bug imho :)
------------------------------------------------------------------------
[2002-03-03 17:35:31] [email]mfischer@php.net[/email]
I'm not satisfied with this answer :-)
Why does it work with arrays but not with strings (and, bert, yeah I
know they aren't the same).
Just because "it's strings here" doesn't legitimate that a warnings is
thrown. Using your suggestion is rather cumbersome.
Is it an implemention issue? Can it be solve to be less long winded?
"it is"
a bug imho :)
------------------------------------------------------------------------
[2002-03-03 17:28:03] [email]derick@php.net[/email]
It's not a bug, $foo{3}. "\n" is done before the @, so that displays
the error.
so I'm closing this, this works BTW:
$foo = "foo"; echo @($foo{3}. "\n");
Derick
------------------------------------------------------------------------
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/14066[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=14066&edit=1[/url]
php at pleaseletusknow dot com Guest
-
#39018 [NEW]: Error control operator '@' fails to suppress "Uninitialized string offset"
From: mpb dot mail at gmail dot com Operating system: Gentoo Linux PHP version: 5.1.6 PHP Bug Type: Scripting Engine problem... -
Invalid branch target position offset for goto
I'm having the same problem with MX6.1... anyone have any more clues? I am also trying to cfinclude a page. -
#26281 [Ver->Csd]: switch on string offset crashes w/bus error
ID: 26281 Updated by: iliaa@php.net Reported By: tater at potatoe dot com -Status: Verified +Status: ... -
#26281 [Opn->Ver]: switch on string offset crashes w/bus error
ID: 26281 Updated by: iliaa@php.net Reported By: tater at potatoe dot com -Status: Open +Status: ... -
#26281 [NEW]: switch on string offset crashes w/bus error
From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 5CVS-2003-11-16 (dev) PHP Bug Type: Strings related...



Reply With Quote

