Can I instantiate a PHP class inside another class? -


I was wondering if he was allowed to make an example of a class inside another class.

, would I have to make it out and then have to pass it through the constructor?

Example (a database class):

  class something {if (.....) {Include SITE_ROOT 'application /' 'db.class.php '; $ Db = new db  

You can not define a square in another class. You should include files with other classes outside the classroom In your case, it will give you two top-level class db and some . You can now create an example of db in the manufacturer of some . For example:

  included SITE_ROOT 'application /' 'db.class.php'; Class some {public function __ composition () {if (...) {$ this-> Db = new db; }}}  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -