D
D
Dom Alfro2019-05-09 19:17:51
PHP
Dom Alfro, 2019-05-09 19:17:51

Question about php objects?

Good day !
I would like to ask, I can’t understand - no matter where I look, I can’t find about the fact that in the arguments of the called function you can create a function or an object
, the code from cakephp will be given and here I just can’t understand what goes where and where.
I tried to find it and for a month now I can not find the necessary information for myself.
he creates on the go or calls?

Router::scope('/', function ($routes) {
    $routes->connect('/', ['controller' => 'Articles', 'action' => 'index']);
});

How can you explain such a construction - that is, it calls a static method (as I think) and uses the '/' separator in it, then creates a function in which there is also a routes argument and starts calling - that is, assigning the name of the controller (I feel that it is close but I don’t understand how it all works)
Help someone with what they can - well, in a sense - understand

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman PHP, 2019-05-09
@mustang_shelby

the static method is called with the first parameter of the string type and the second parameter of the callable pseudotype. callable means that this value can be called as a function. the declaration of this function is given when calling, i.e. this most callable-value is initialized. inside the Router::scope static method, this value will be called as a function that takes one parameter and calls its connect(string, array) method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question