Keyword "use" in php

2

I was using an api when I came across the following code:

$push->on('incoming', function (\InstagramAPI\Push\Notification $push) use ($ig, $socket) {
    ...
});

I realized that the word "use" is used to use a certain variable within the scope of that internal function, but it was only a conclusion I drew, what I wanted to know is if it is simply this and the end point or if there is something more.

When I search for 'use' in php it only appears on the 'use' to import classes, for example:

use React\EventLoop\Timer\TimerInterface;

The closest I got to the answer was this:

  

use does not include anything. It just imports the specified namespace   (or class) to the current scope

Source: #> link

But it talks only about classes and namespace nothing about variables, I wanted to know more about this word 'use', because I have some difficulties to use this api and it uses a lot of this feature and I do not want this doing something wrong for not knowing how to use the feature.

    
asked by anonymous 10.01.2018 / 19:14

0 answers