21,886
社区成员
发帖
与我相关
我的任务
分享
class A
{
var $afterEditFun;
function editRow()
{
//.......
if($result)
{
if(!empty($this->afterEditFun) && is_callable($this->afterEditFun))
{
call_user_func($this->afterEditFun,$idArr,$this->primaryKeyCol,$afterEditArray);
}
}
}
function setConfig($var,$value) //e.g. $var=afterEditFun, $value=array(&$this,'sendNotice')
{
if($var == 'varPrefix') //varPrefix=id-tablename
{
// If the variable prefix changed, update variables with session values
$varPrefix = $value;
foreach($_SESSION as $sessKey => $sessValue)
{
if(substr($sessKey,0,strlen($varPrefix)) == $varPrefix)
{
$varName = str_replace($varPrefix,'',$sessKey);
$this->{$varName} = $sessValue;
}
}
}
if(!isset($_SESSION[$this->varPrefix.$var])) //$_SESSION[id-tablename.afterEditFun]
{
$this->{$var} = $value; //$this->{afterEditFun} = array(&$this,'sendNotice')
}
}
}
require_once('php/A.php');
function ()
{
//........
$Editor = new A( );
$Editor->setConfig('afterEditFun',array(&$this,'sendNotice'));
//.........
}
funciton sendNotic()
{
//..............
}