php classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FrEaKmAn
    New Member
    • Aug 2007
    • 46

    php classes

    Hello,

    I have this simple but weird thing, at least for me

    [PHP]
    <?php

    class a{
    function __construct(){
    $this->data='6';
    b::b();
    //$a=b::b();
    }

    function get(){
    exit($this->data);
    //exit($a);
    }
    }

    class b{
    function b(){
    $this->data='9';
    return $this->data;
    }
    }

    $a = new a();
    $a->get();
    ?>
    [/PHP]

    output is 9, but I would expect to be 6. If I call the b::b, I would suspect that return value could be stores in a variable ($a), but instead everything that was set in function b overwrites the same variables in class a... is this normal?
  • aktar
    New Member
    • Jul 2006
    • 105

    #2
    Hmmm..

    I suspect its a bug

    Comment

    Working...