php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12964 direct access to an array fails but walkthrough by foreach works
Submitted: 2001-08-26 06:26 UTC Modified: 2001-08-26 07:46 UTC
From: jan at kneschke dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
 [2001-08-26 06:26 UTC] jan at kneschke dot de
It seems that I've reached one of the borders of PHP/Zend.

I'm coding a qt-like environment called pasta which 
results in a quite large class-tree. This is a problem for 
PHP as it looses a some parts of the class:

The code:
        print_r($this->sec_global);
        print "incpath: 
".$this->sec_global["includepath"]."\n";
        foreach($this->sec_global as $k => $v) {
            print "$k -- $v<br />";
        }

results in the following output:

Array
(
    ["debug_level"] => 0
    ["incremental"] => 0
    ["enable_resolver"] => 1
    ["outputdir"] =>
    ["include"] =>
    ["includepath"] => ../etc/
)
 
 
Warning:  Undefined index:  includepath in 
/pages/projects/modlogan/mlaconfiggen.php on line 262
 
incpath:
"debug_level" -- 0
"incremental" -- 0
"enable_resolver" -- 1
"outputdir" --
"include" --
"includepath" -- ../etc/


As you can see a print_r and foreach display the same 
result. The array is filled with these data like I've 
expected it. But a direct access to the array results in a 
'undefined index' which looks very odd to me.

This problem exists for other class variables of this 
class too:

Undefined property: processorplugin ...

This happens in the default branch of a switch.

The full code can be found at 
http://jan.kneschke.de/showsource.php?page=%2Fprojects%2Fmodlogan%2Fmlaconfiggen.php

The output is at
http://jan.kneschke.de/projects/modlogan/mlaconfiggen.php

(click 3 times on the '-->', fill in some data into the 
4th page and click on '-->' again. This will result in the 
described behaviour which has been reproduced with 
PHP4.0.6 and PHP4.0.7rc1)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-26 07:46 UTC] mfischer@php.net
Jan,

It's our all paperbag since you consultet a few not-so-newbie people before submitting ... ;-)

cheers,
 Markus

--
All the paperbags are belong to #php.de
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 05:01:30 2024 UTC