If I got two classes extending a 3rd classs will the content of the 3rd class be instantiated twice when instantiating both, the 1st and 2nd class?
Example:
class class1 extends class3{}
class class2 extends class3{}
class 3{
$this->db = new mysql();
}
$class1 = new class1();
$class2 = new class2();
On the example above will the db object be created two times? , on this case, resulting in 2 connections to mysql?
Thanks,
first,
class 3{
$this->db = new mysql();
}
would not run as there is a syntax error. you can't have code in a class unless it is in a method. I assume you meant the object creation line to be in the class constructer method __construct(). In this case the code would be run each time any of the classes were instantiated. this is unless of course you have overwritten the method in one of the entended classes.