Skip to content
Advertisement

How to use external function in php route

I am building simple php route But I I have the following, which is working

JavaScript

My challange is that… I want to be able to load the function directly from a controller which I am calling

JavaScript

the login() is a function i created inside LoginController class I get this error

JavaScript

My Route.php

JavaScript

Is there anyway i can make use of external function inside the route?

Advertisement

Answer

It wants a callback, so you need to pass a function itself. In your case using the parenthesis () invokes (calls) the function and returns the result of it instead of passing the function itself.

So here is a simple example of how you could do it:

JavaScript

Wrapping it into a another function enables you to even pass arguments.

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement