Abudayah
Abudayah

Reputation: 3875

PHP 5.3 Function name must be a string

I got an error Function name must be a string on this line, I think it's might be a compatibility problem because this line was written in php 7

public static $renderers = array();

public static function somefunction($tpl, $params)
{
return self::$renderers[$tpl]($params);
}

Upvotes: 3

Views: 462

Answers (1)

DarkBee
DarkBee

Reputation: 15633

You need to assign the closure to a variable first before you can execute it,

$foo = self::$renderers[$tpl];
$foo($params);

Upvotes: 1

Related Questions