I know there is a difference in class variables and instance variables in programming languages like Java and C#, so I was wondering if PHP is the same.
So I know class variables is shared among all the instances of that class whereas instance variables is only relevant to that specific instance of that class.
For example:
class db {
private $host; <--
private $user; <-- These will be treated as instance variables
private $pass; <-- as they are set by the class constructor
private $dbname; <--
private $connected = false; <-- Will this be treated as a class
variable? Shared among all the
instance of the db class?
public function __construct($host, $user, $pass, $dbname) {
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->dbname = $dbname;
}
public function checkConn() {
// some code here to change the value of $this->connected
}