Vote Up 0 Vote Down

How to pass a function in the brackets?

If you look at the documentation , you will see the following line:

attr($key, $fn) Set a single property to a computed value, on all matched elements.

Can you please tell how to pass a function in brackets? As far as I know, the bracketed function can not write, then what is meant here?
flag
php

Answers


Vote Up 0 Vote Down
As Far As. PHP can cause:

A string containing the Fully qualified function name: \Name\Space\fnc . For obvious reasons, most commonly used functions without namespaces, such array_map('intval', $idList); .
A string containing the Fully qualified static Method name \Name\Space\Clazz::method . This will bring up the corresponding static method.
Anonymous function (in reality - an instance of Closure)
An object that has a method __invoke() (in the previous paragraph)
Array consisting of an object and the method name: array($this, 'init')

Eat it all in stride and perform call_user_func / call_user_func_array() , one of which is likely lies inside the method phpquery.
flag | link |

Your Answer

Login before answering

Login with facebook