Re: Object In Object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Dinçer akay <dincer@xxxxxxxxxxxxxx>:
> Is this a good way ?
> <?
>
> class main{
>     var $mysql;
>     var $user;
>     function main(){
>         $this->mysql=new mysql();
>         $this->user=new user();

If you're developing strictly for PHP5, this will work fine. However, if
you're in PHP4, you're going to want to use references. Try the
following:

          $mysql       =& new mysql();
          $this->mysql =& $mysql;
          $user        =& new user();
          $this->user  =& $user;

Other than that, yes, this is a fairly standard mechanism in PHP's OOP.

-- 
Matthew Weier O'Phinney           | mailto:matthew@xxxxxxxxxx
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux