I think you should have an accessor method, rather than accessing it directly. Let me show you why:
$mysqli = new dbconnect();
echo $mysqli->db_link; // echos 'Resource 19' or something like that
$mysqli->db_link = 'I\'ve got a lovely bunch of coconuts...';
echo $mysqli->db_link; // echos "I've got a lovely bunch of coconuts..."
With an accessor method, you'd take away the ability to directly modify the variable to some classes; however, only in PHP5 can you really make $this->db_link private and really protect it. But your accessor method would be:
class dbconnect {
var $db_link;
/* ... */
function getDBLink() {
return $this->db_link;
}
/* ... */
}
Now instead of doing what you have above, you can do this:
$mysqli = new dbconnect();
$dbc = $mysqli->getDBLink();
Now $dbc will hold a copy of the $db_link var from within your class. Much better, especially since if later on you want to change it from $db_link to something like $db_link_identifier_resource_variable. You'd change only your class, not every script you call it in 😉