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 PROTECTED]

Since we now have this 'wont fix' status, let's use it. :)


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

[2002-03-03 17:47:39] [EMAIL PROTECTED]

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 PROTECTED]

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 PROTECTED]

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 PROTECTED]

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
    http://bugs.php.net/14066

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

Reply via email to