选择语言 :

 Core_Arr::callback

Creates a callable function and parameter list from a string representation. Note that this function does not validate the callback string.

// Get the callback function and parameters
list($func, $params) = Arr::callback('Foo::bar(apple,orange)');

// Get the result of the callback
$result = call_user_func_array($func, $params);
array Core_Arr::callback( string $str )

参数列表

参数 类型 描述 默认值
$str string Callback string
返回值
  • array function, params
File: ./core/classes/arr.class.php
public static function callback($str)
{
	// Overloaded as parts are found
	$command = $params = null;

	// command[param,param]
	if (preg_match('/^([^\(]*+)\((.*)\)$/', $str, $match))
	{
		// command
		$command = $match[1];

		if ($match[2] !== '')
		{
			// param,param
			$params = preg_split('/(?<!\\\\),/', $match[2]);
			$params = str_replace('\,', ',', $params);
		}
	}
	else
	{
		// command
		$command = $str;
	}

	if (strpos($command, '::') !== FALSE)
	{
		// Create a static method callable command
		$command = explode('::', $command, 2);
	}

	return array($command, $params);
}