php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34198 Class Member Visibility
Submitted: 2005-08-20 20:54 UTC Modified: 2005-08-21 13:37 UTC
From: kuprishuz at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.0RC1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kuprishuz at gmail dot com
New email:
PHP Version: OS:

 

 [2005-08-20 20:54 UTC] kuprishuz at gmail dot com
Description:
------------
appears to be problems with class member variable visibility causing application to be completely un-useable, i have also attempted to echo member variables in the same method but they are always blank.

Reproduce code:
---------------
class system {
    public $errorobj;
    public $databaseobj;
    function __construct() {
        $this->errorobj = new error($this);
        $this->databaseobj = new database($this);
    }
}
class database {
    function __construct($system) {
       $this->system = $system;
       get_class($this->system->errorobj);
    }
}


Expected result:
----------------
should return the object name "error"

Actual result:
--------------
returns "non-object" error message

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-21 13:37 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please submit the code that outputs anything!

Now look at this:
<?php

//class error
//{
//}

class system
{
    public $errorobj;
    public $databaseobj;
    function __construct()
    {
        $this->errorobj = new error($this);
        $this->databaseobj = new database($this);
    }
}
class database
{
    function __construct($system)
    {
       $this->system = $system;
       var_dump(get_class($this->system->errorobj));
    }
}

new database(new system());

?>


marcus@zaphod /usr/src/php-cvs $ php ~/tmp/bug34198.php
make: `sapi/cli/php\' is up to date.

Fatal error: Class \'error\' not found in /home/marcus/tmp/bug34198.php on line 13
marcus@zaphod /usr/src/php-cvs $

When i enable the commented code, e.g. provide a class error:
marcus@zaphod /usr/src/php-cvs $ php ~/tmp/bug34198.php
make: `sapi/cli/php\' is up to date.
string(5) \"error\"
string(5) \"error\"

So you have an error anywhere else or in your design.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC