nesting classes in php

Posted by Honey on Stack Overflow See other posts from Stack Overflow or by Honey
Published on 2010-05-13T23:03:45Z Indexed on 2010/05/13 23:24 UTC
Read the original article Hit count: 477

Filed under:
|
|

here is my sample class to why i want to nest.

include("class.db.php");

class Cart {

function getProducts() {

//this is how i do it now. 
//enter code here`but i dont want to redeclare for every method in this class. 
//how can i declare it in one location to be able to use the same variable in every method?
$db = new mysqlDB;


$query = $db->query("select something from a table");
return $query

}

}

© Stack Overflow or respective owner

Related posts about php

Related posts about class