You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
907 B

<?php
/**
* User: u73376
* Date: 2018/8/17
* Time: 9:37
*/
class MethodLoader
{
#临时类文件存放目录
/**
* @param $methodString 可以转为方法的字符串
* @return object
*/
static function getInstanceByMethodString($methodString)
{
$obj = new class($methodString)
{
private $methodString;
public function __construct($methodString)
{
$this->methodString = $methodString;
}
public function invokeMethod($flow, $form)
{
//function[\s\n]+(\S+)[\s\n]*\(
preg_match_all("/function[\s\n]+(\S+)[\s\n]*\(/", $this->methodString, $arr);
eval($this->methodString . ";");
$func=$arr[1][0];
return $func($flow, $form);
}
};
return $obj;
}
}