I am using Cakephp2.0 i created a custom function
<?php echo GenerateNavHTML($navarray); ?>
<?php
function GenerateNavHTML($nav)
{
if(!empty($nav)) {
if(isset($nav[0]['parent'])) {
$parentid=$nav[0]['parent'];
}else{
$parentid=1;
}
if($parentid==0) {
$html = '<ul style="display: block;" class="nav">';
}else {
$html='<ul>';
}
foreach($nav as $page) {
$html.='<li>';
$html .= '"'.$this->Html->url('Logout',array('controller'=>'users','action'=>'logout')).'"';
$html .= '</li>';
}
$html.='</ul>';
return $html;
}
}
?>
and it give
Fatal error: Cannot redeclare GenerateNavHTML()
But there is no redeclaration of function.
if i write
<?php
function GenerateNavHTML($nav)
{
if(!empty($nav)) {
if(isset($nav[0]['parent'])) {
$parentid=$nav[0]['parent'];
}else{
$parentid=1;
}
if($parentid==0) {
$html = '<ul style="display: block;" class="nav">';
}else {
$html='<ul>';
}
foreach($nav as $page) {
$html.='<li>';
$html .= '<a href=""></a>';
$html .= '</li>';
}
$html.='</ul>';
return $html;
}
}
?>
and it is working fine
i want to use cakephp syntax
Thanks