I have a method in a controller say like this. In fact, I'm in need to declare a function checkLogin so that I can use in several Controller method like below:
class DefaultController extends Controller
{
/**
* @Route("/test")
* @Template()
*/
public function testAction()
{
if (checkLogin()){}
else {}
exit;
}
public static function checkLogin()
{
return 1;
}
}
In the above case, when I'm doing it like this, I'm getting the following error:
Fatal error: Call to undefined function NouPei\WebSiteBundle\Controller\checkLogin() in /home/noor/noupei/website/WebSiteBundle/Controller/DefaultController.php on line 142
It's a method, not a function:
if (self::checkLogin()){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With