Reputation: 13552
I have a CakePHP application works fine with PHP: 5.3.8. However, it generates the following error with PHP: 5.5.9
Non-static method AppHelper::isCurrent() should not be called statically, assuming $this from incompatible context
in View/Themed/Slate/Helper/AppHelper.php
I have made this code:
function isCurrent($txt, $className = 'active'){
if ($txt == strtolower($this->name.$this->action)){
return $className;
}
else{
return '';
}
}
In the past, before upgrade the PHP, I used to call this function from the view as follows:
<?php echo AppHelper::isCurrent('contactsindex', 'active'); ?>
I tried to prefix the function name with public static
to void this error but it failed to solve this issue. I need to know how to fix this issue?
Upvotes: 0
Views: 548
Reputation: 4776
tr this
//View/Helper/AppHelper
class AppHelper extends Helper {
public function isCurrent($txt, $className = 'active'){
if ($txt == strtolower($this->name.$this->action)){
return $className;
}
else{
return '';
}
}
}
//View
<?php echo $this->Html->isCurrent('contactsindex', 'active'); ?>
Upvotes: 1