我已經使用了全局變量和靜態變量來使得第二個調用中的值可用。但它給了我同樣的錯誤。如何在PHP中第二次調用變量值?
public function iCheckTimeStampofAjaxAndLite($Version,$Date)
{
$node = $this->getMainContext()->getSession()->getPage()->find('css', $Date);
print_r("Count:" .sizeof($node)); echo "\n";
$DateText=(string)$node->getText();
if ($Version=='Ajax'){
static $AjaxDate;
$AjaxDate=$DateText;
print_r("AjaxDate:" .$AjaxDate); echo "\n";
return;
}
else{
if ($AjaxDate==$DateText){
print_r("DateText:" .$DateText); echo "\n";
return;
}
else{
throw new Exception("Both Date are not Same");
}
}
}
1st call -> iCheckTimeStampofAjaxAndLite("Ajax","1.50pm");
2nd call -> iCheckTimeStampofAjaxAndLite("Lite","3.50pm");
Output : (Notice: Undefined variable: AjaxDate)
請學什麼[得墨忒耳定律(http://en.wikipedia.org/wiki/Law_of_Demeter)是。 –