Newbie: handling instance values on a attribute of the same class.

From: Date: Thu, 09 Apr 2009 16:15:58 +0000
Subject: Newbie: handling instance values on a attribute of the same class.
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-291302@lists.php.net to get a copy of this message
Hi all, Ok. Here is a code that I'm studying: class Connection extends PDO { private $dsn = 'mysql:dbname=testes;host=127.0.0.1'; private $user = 'root'; private $password = ''; public $handle = null; function __construct( ) { try { if ( $this->handle == null ) { $dbh = parent::__construct( $this->dsn , $this->user , $this->password ); $this->handle = $dbh; return $this->handle; } } … Can I replace this part: $dbh = parent::__construct( $this->dsn , $this->user , $this->password ); $this->handle = $dbh; return $this->handle; By this: (?) $this->handle = parent::__construct( $this->dsn , $this->user , $this->password ); And put a return on my getHandler method? If so, is there any special reason that we should know about using a structure like this? $dbh = parent::__construct( $this->dsn , $this->user , $this->password ); $this->handle = $dbh; return $this->handle; Thanks a lot, Márcio

« previous php.general (#291302) next »