|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24837 Incorrect behaviour of PPP using foreach
Submitted: 2003-07-28 02:39 UTC Modified: 2003-12-22 05:39 UTC
Avg. Score:2.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: redeye at erisx dot de Assigned: helly
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-11-29 OS: *
Private report: No CVE-ID:
 [2003-07-28 02:39 UTC] redeye at erisx dot de
Using a foreach ( or while ) loop to print the
content of an object should to my understanding
skip private and protected values ( or methods ).

Actually these values are returned but missing
their respective keys, so at least their source
is hidden.

Reproduce code:

class test {
    private   $foo = 'test foo';
    private   $bar = 'test bar';
    protected $foobar = 'test foobar';

$test = new test;
foreach ( $test AS $key => $val ){
    echo $key." => ".$val."\r\n";


Expected result:
empty page :)

Actual result:
 => test foo
 => test bar
 => test foobar


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-18 17:01 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

 [2003-12-22 03:59 UTC] redeye at erisx dot de
Also variables are hidden now, methods are still visible
using the function get_class_methods([obj]);
 [2003-12-22 05:39 UTC]
get_class_methods([obj]); has nothing to do with the above error. Please open a new bug report and explain in detail.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 09:01:35 2015 UTC