当A类扩展B类时,它们都具有相同的属性

I have class A and class B. where class A extends class B.

They both have the property $fields, where $fields is an array, like:

class A fields

public $fields = array( 'id'=>'', 'product'=>'', 'productXpath'=>'', 'price'=>'', 'priceXpath'=>'', 'currency'=>'', 'website_url'=>'', 'url_id'=>'', 'day'=>'', 'month'=>'', 'year'=>'', 'time'=>'', 'status'=>'' );

class B fields

public $fields = array( 'id'=>'', 'website'=>'', 'visits'=>'', 'plugin_id'=>'', 'status'=>'' );

Only the structure and values within the array are different.

I need to access both properties, how do i do this ?

Edit:

If you have control over class B, simply define a getter and make $fields private:

public function getFields() {
    return $this->fields;
}

Then in class A you can do:

public function getFields() {
    $parentFields = parent::getFields();
    // Do something with $parentFields
    return $this->fields;
}

If not, you'll have to give a different name to the $fields property in class A, so as not to lose the value of class B.

make the property as static

public static $fields = array(...);

and get access to the variable by

echo ClassName::$fields;