I am getting the error \"Undefined variable: interval in C:\\wamp\\www\\DGC\\classes\\DateFilter.php\"
Here is my code for the DateFilter class:
clas
$interval
is local to the function. $this->interval
references your private property.
class DateFilter extends Filter
{
//@param daysOld: how many days can be passed to be included in filter
//Ex. If daysOld = 7, everything that is less than a week old is included
private $interval;
public function DateFilter($daysOld)
{
echo 'days old' . $daysOld .' br>';
$this->interval = new DateInterval('P'.$daysOld.'D');
}
function test()
{
echo $this->interval->format("%d days old ");
//echo 'bla';
}
}