Позвоните parent::__construct()
в a::__construct()
:
class a extends b
{
public function __construct()
{
parent::__construct();
}
public function validateStuff()
{
$this->insert_record();
}
}
. Вы можете вообще не указывать конструктор a, если вы не делаете какой-то специфической вещи.
If both approaches are as easy to use in your code, go for storing a single object. It avoids the extra overhead of calling the data()
method every time you need a value. This way, you can fetch the mapping object with one call to data()
, and then retrieve values from this object as many times as you want without having to call data()
again.
The data()
method uses objects to map elements to keys/values under the hood, so it does not offer any performance improvements over managing a mapping object yourself.
Я бы, вероятно, сделал что-то вроде:
var data = $("#div_id").data();
data.foo=1;
data.bar=2;