jordanwb Posted November 15, 2007 Share Posted November 15, 2007 I'm making a MySQL class for easy database access. In the constructor I call mysql_connect and save the result in $connection which is an instance variable. Is it possible to make it private? Also can I declare constants in a class and have them accessable like so: class foo { define ("CONST", 7); } $foo = new foo; print foo->CONST; Quote Link to comment Share on other sites More sharing options...
aschk Posted November 15, 2007 Share Posted November 15, 2007 Is it possible to make what private? The $connection? And yes you can put constants into your classes. e.g. class MySQL { const MYCONSTANT = 7; private $connection; public function __construct(){ $this->connection = mysql_connect(....etc....); } } Quote Link to comment Share on other sites More sharing options...
jordanwb Posted November 15, 2007 Author Share Posted November 15, 2007 Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.