Jump to content

php + oop


Sld
 Share

Recommended Posts

Viva,

Tenho os seguintes exemplos:

class a {

public $object_b;

public $value;

public function __construct() {

$this->object_b = new b(&$this);

$this->value = 1;

}

}

class b {

public $object_a;

public function __construct($a) {

$this->object_a = $a;

var_dump( $this->object_a );

}

}

$a = new a();

Ao fazer o var_dump, o value da classe a mantém-se a NULL, dado que à classe b lhe foi passado o endereço do objecto a, o value não devia estar a 1?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.