Re: Confusion with objects
| From: | Geoff Hankerson | Date: | Wed, 07 Aug 2002 13:47:43 +0000 |
| Subject: | Re: Confusion with objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111503@lists.php.net to get a copy of this message | ||
Seems to me that it should be more like this:
class Db
{
var $host;
var $user;
var $password;
// Note the constructor function run automatically when the class is called
because it has the same name as the class
function Db {$host, $user, $password)
$this->host=$host;
$this->user=$user;
$this->password = $password;
$result = @mysql_connect($this->host, $this->user, $this->password');
if(!$result)
return false;
else
return true;
}
}
Now you can call the class like this:
$myDb = new Db('myHost', 'myUser','myPassword');