Answer the question
In order to leave comments, you need to log in
Anonymous function inside PHP array?
Below is the code where the nav() method returns the processed data.
The problem is with the anonymous function. It is necessary for me in this order that the script would work out and return the data, as in js. Where are the errors in the code or is it not possible?
Mistake:
Catchable fatal error: Object of class Closure could not be converted to string in
<?
class header {
public function nav (){
return view::tpl('header', array (
'navigation' => function (){
$sql = sql::getInstance();
// Получаем список модулей
$sql->where('nav', 'head');
$modules = $sql->get('modules', null, array('name', 'module', 'nav'));
foreach ($modules as $module){
view::tpl('header-nav',array(
'name' => $module['name'],
'link' => $module['module'],
'class' => router::$module === $module['module'] ? 'active' : ''
));
}
}
));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question