我不確定標題是否正確,我的問題是我有一個類和它的函數,我想檢查函數的值是否設置,如果不設置其他值如何檢查一個函數是否有值
class some_class
{
private $width;
function width($value)
{
// Set another default value if this is not set
$this->width = $value;
}
}
$v = new some_class();
// Set the value here but if I choose to leave this out I want a default value
$v->width(150);
如果您使用setter方法,請按原樣調用它:'setWidth'。 – jeremy