the problem i have with that is....
PHP Code:
class Foo
{
private $var = 'I am private';
private $num = 2345.34; // should not be changed or made known unless its changed by Foo due to certain criteria.
public function getVar()
{
return $this->var;
}
public function Calculate()
{
return ($this->num + (12 % 3) * pow(4 - 234, 34));
}
}
class Bar extends Foo
{
// let's imagine for a moment that this is possible in PHP, as it should be:
private $var = 'I am modified';
private $num = '0';
}
$x = new Bar();
$x->Calculation();
$x->getVar(); // in theory, correct me if i am wrong, but getVar() would then return 'I # am modified'; which
# if i didn't want someone to do, for that value for whatever reason, could cause
# trouble if they were not supposed to have access to it in the first place in an inherited class. now.
# if that is the case. then what if you were doing a calculation with values that
# should be only modified a certain way?
Bookmarks