我有一节课
class Product {
public $name;
private $price2;
protected $number;
function getNmae() {
return $this->name;
}
function getPrice() {
return $this->price2;
}
function getNumber() {
return $this->number;
}
}
在这里我可以使用私有价格,没有任何问题?
<?php
include 'oop_test.php';
class Banana extends Product {
}
$ba = new Banana();
echo $ba->price2 = 2000;
?>
我不明白如何为私有变量赋值?