use is not a function, it's part of the Closure syntax. It simply makes the specified variables of the outer scope available inside the closure.

bar = function () {
    // can't access $foo in here
    echo $foo; // undefined variable
};

$baz = function () use ($foo) {
    // $foo is made available in here by use()
    echo $foo; // 42
}

For example:

$array = array('foo', 'bar', 'baz');
$prefix = uniqid();

$array = array_map(function ($elem) use ($prefix) {
    return $prefix . $elem;
}, $array);

// $array = array('4b3403665fea6foo', '4b3403665fea6bar', '4b3403665fea6baz');
Answer from deceze on Stack Overflow
๐ŸŒ
DEV Community
dev.to โ€บ robertobutti โ€บ mastering-php-namespaces-simplifying-code-with-use-function-for-external-functions-38fb
PHP, Functions, and Namespaces with the "use function" statement - DEV Community
July 28, 2024 - In this example, we've defined the namespace MyApp and imported the add() function from the MyMath namespace using the use function statement. Now, let's see how we can define an alias for the imported function: // example_3.php namespace MyApp; require_once 'math_functions.php'; use function MyMath\add as myAddFunction; $result = myAddFunction(10, 5); echo 'Result: '.$result; // Output: Result: 15
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ functions.anonymous.php
PHP: Anonymous functions - Manual
Consider the following example: <?php class MyClass { const member = 1; public $member; public function member () { return "method 'member'"; } public function __construct () { $this->member = function () { return "anonymous function 'member'"; }; } } header("Content-Type: text/plain"); $myObj = new MyClass(); var_dump(MyClass::member); // int(1) var_dump($myObj->member); // object(Closure)#2 (0) {} var_dump($myObj->member()); // string(15) "method 'member'" $myMember = $myObj->member; var_dump($myMember()); // string(27) "anonymous function 'member'" ?> That means, regular method invocations work like expected and like before. The anonymous function instead, must be retrieved into a variable first (just like a property) and can only then be invoked. Best regards, ... <?php /* * An example showing how to use closures to implement a Python-like decorator * pattern.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ php_functions.asp
PHP Functions
json_decode() json_encode() json_last_error() PHP Keywords ยท abstract and as break callable case catch class clone const continue declare default do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile extends final finally fn for foreach function global if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try use var while xor yield yield from PHP Libxml
๐ŸŒ
Codecademy
codecademy.com โ€บ learn โ€บ learn-php-functions โ€บ modules โ€บ introduction-to-functions-in-php โ€บ cheatsheet
Learn PHP: Functions: Introduction to Functions in PHP Cheatsheet | Codecademy
A variable with local scope can only be accessed within the function it is declared. A variable with global scope can be accessed from multiple functions in the PHP script. ... Learn how to use built-in PHP functions to complete common (and some niche) tasks and create your own functions to reuse blocks of code.
Find elsewhere
๐ŸŒ
Zend
zend.com โ€บ blog โ€บ what-php-function
What Is a PHP Function? | Functions in PHP With Examples | Zend
January 30, 2020 - Built-in PHP functions ship with PHP runtimes and their extensions โ€” and they can be called from anywhere in a script (for example, print(), var_dump(), mysql_connect(), etc.). User-defined functions are custom functions that developers create.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ php-functions
PHP | Functions - GeeksforGeeks
November 28, 2025 - PHP supports anonymous functions, also known as closures. These functions do not have a name and are often used for passing functions as arguments to other functions.
๐ŸŒ
Fisher-fleig
bryce.fisher-fleig.org โ€บ php-what-does-function-use-syntax-mean
PHP: What Does function ...() use () syntax mean?
January 31, 2014 - Just like normal function parameters, parameters provided to the closure scope via the use keyword are passed by value. To pass parameters by reference, simply add an ampersand (&) in front of the parameter. I've been trying to figure out to hack together a pure PHP server using PHP 5.3 for a special side project, and I came upon the excellent static site generator called Sculpin.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ php_operators.asp
PHP Operators
json_decode() json_encode() json_last_error() PHP Keywords ยท abstract and as break callable case catch class clone const continue declare default do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile extends final finally fn for foreach function global if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try use ...
๐ŸŒ
Dinocajic
dinocajic.com โ€บ home โ€บ programming โ€บ php โ€” p40: use keyword
PHP use Keyword - Function Scope
November 6, 2023 - You could, of course, pass the global variable as an argument, but if you need to use the use function, thatโ€™s how you would do it. There are benefits to doing both as was outlined above. <?php $global_variable = "Dino Cajic"; $closure = function($greeting) use($global_variable) { echo $greeting .
๐ŸŒ
OnlinePHP
onlinephp.io
PHP Sandbox - Execute PHP code online through your browser
Run PHP code in your browser online with this tool in 400+ PHP versions
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ php-tutorial โ€บ php-functions.php
How to Define and Call a Function in PHP - Tutorial Republic
In such cases, you can use the global keyword before the variables inside a function. This keyword turns the variable into a global variable, making it visible or accessible both inside and outside the function, as show in the example below: ... <?php $greet = "Hello World!"; // Defining function function test(){ global $greet; echo $greet; } test(); // Outpus: Hello World!
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ php โ€บ php_use_statement.htm
PHP The "use" Statement
Closure is also an anonymous function that can access variables outside its scope with the help of the "use" keyword. ... <?php $maxmarks=300; $percent=function ($marks) use ($maxmarks) { return $marks*100/$maxmarks; }; $m = 250; echo "marks=$m percentage=".
๐ŸŒ
SitePoint
sitepoint.com โ€บ php
PHP: Calling a function inside a class? - PHP - SitePoint Forums | Web Development & Design Community
February 22, 2022 - FYI: A function within a class is called a Method. <?php class MyClass { function myMethod(){ return 'My Method'; } } $demo = new MyClass(); echo $demo->myMethod(); jeremy58 February 22, 2022, 5:18pm ยท 4 ยท I have the code below. I need to acces the function send_to_flow($params = null,$to_phone = null,$input_phone = null) send_to_flow is there to package up the inputs and send them to Twilio so it can do its thing.
๐ŸŒ
PHP
wiki.php.net โ€บ rfc โ€บ use_function
PHP: rfc:use_function
May 2, 2013 - PHP offers the ability to import namespaces and types (classes/interfaces/traits) via the use statement. This capability however does not exist for functions.