pizzaman
05-05-2005, 12:41 AM
For example, I have the following code:
<?php
class foo //parent class
{
protected $foovariable;
public function FooFun(bar $BarObj)
{
$BarObj->barvariable = 1; //this is fine
}
}
class bar extends foo //child class extends foo
{
protected $barvariable;
public function BarFun(foo $FooObj)
{
$FooObj->foovariable = 1; //but this gives me a access violation error
}
}
?>
I thought with the protected the child class can access the parent class' variables directly. Unless that is only if the parent class is not passed in as a function parameter?
-Pizzaman
<?php
class foo //parent class
{
protected $foovariable;
public function FooFun(bar $BarObj)
{
$BarObj->barvariable = 1; //this is fine
}
}
class bar extends foo //child class extends foo
{
protected $barvariable;
public function BarFun(foo $FooObj)
{
$FooObj->foovariable = 1; //but this gives me a access violation error
}
}
?>
I thought with the protected the child class can access the parent class' variables directly. Unless that is only if the parent class is not passed in as a function parameter?
-Pizzaman