Re: function as arguments to functions(constructors)

From: Date: Thu, 27 Jul 2000 01:26:58 +0000
Subject: Re: function as arguments to functions(constructors)
Groups: php.general 
Request: Send a blank email to php-general+get-8455@lists.php.net to get a copy of this message
I found out how to do it. The key is to make a $tmp variable in the scope that you are going to use the function. The syntax $this->classname() does not work for a variable holding the name of a function. It fails the parse for the function named 'classsname'. but if you do this instead: $tmp=$this->classname; $tmp(); it works. Below is my object design to use this: <?php class SafeTypedSTR{ var $STR; var $TypingFunc; function SafeTypedSTR($ExtTypingFunc){ echo("b4 function usage"); if(!empty($ExtTypingFunc)) $this->TypingFunc=$ExtTypingFunc; } function PutSafeTyped($arg){ if(!isset($this->TypingFunc)) return 0; if(!isset($arg)) return 0; $tmp=$this->TypingFunc; if ($tmp($arg)){ $this->STR=$arg; return 1; } else return 0; } function GetSafeTyped(){ if($this->Validate()) return $this->STR;} function Validate(){ if(!isset($this->TypingFunc)) return 0; if(!isset($this->STR)) return 0; $tmp=$this->TypingFunc; if ($tmp($this->STR)) return 1; else return 0; } } ?> -- ----------------------------------------------------------------- Time Spent With Your Dog(Kid) is Time Well Spent ----------------------------------------------------------------- Sincerely, Dennis Gearon

« previous php.general (#8455) next »