Have you tried using a callback? If the function name passed to do_action is declared within the current object you should be able to perform the following:
call_user_func($this,'update'); Check out the section on callbacks: http://us.php.net/callback and the function call_user_func: http://us.php.net/manual/en/function.call-user-func.php - jake On Dec 6, 2007 9:58 AM, Rick Retzko <[EMAIL PROTECTED]> wrote: > Gents/Ladies - > > Some help please with my PHP5 OOP learning curve: > > I'm trying to use a $this variable to call a function within a class. I > know the following works: > > class actions { > > private $_aData; > private $_table; > > public function __construct(){ > $this->_aData=array(); > $this->_table=FALSE; > } > > private function update(){ > echo 'Update being executed!'; > return TRUE; > } > > //public functions ================================== > public function do_action($table,$data){ > //direct action activity > //assumption: $data['action'] will contain action definition > $this->_table=$table; > $this->_aData=$data; > > $completed=self::update(); //<== THIS IS THE PROBLEM LINE > > return $completed; > > } > } > > When I change that line to > "$completed=self::$this->_aData['action'].'()';" (which contains the string > 'update'), the line is read, but nothing happens. > When I add "$action=$this->_aData['action'].'()';", then change the line > to "$completed=self::$action;", I get the following error message: > *Fatal error*: Access to undeclared static property: actions::$action in > *C:\Program > Files\Apache Software > Foundation\Apache2.2\htdocs\cjmea\hs_choir\classes\class.actions.php5* on > line *37.* > ** > All help is appreciated! > > > Best Regards - > > Rick > [EMAIL PROTECTED] > > > _______________________________________________ > New York PHP Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > NYPHPCon 2006 Presentations Online > http://www.nyphpcon.com > > Show Your Participation in New York PHP > http://www.nyphp.org/show_participation.php >
_______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
