note 126472 added to functions.arguments

From: Date: Sun, 03 Oct 2021 12:20:48 +0000
Subject: note 126472 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-217024@lists.php.net to get a copy of this message
It is worth noting that you can use functions as function arguments <?php function run($op, $a, $b) { return $op($a, $b); } $add = function($a, $b) { return $a + $b; }; $mul = function($a, $b) { return $a * $b; }; echo run($add, 1, 2), "\n"; echo run($mul, 1, 2); ?> Output: 3 2 ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 65.49.211.27) ---- Manual Page -- https://php.net/manual/en/functions.arguments.php Edit -- https://main.php.net/note/edit/126472 Del: integrated -- https://main.php.net/note/delete/126472/integrated Del: useless -- https://main.php.net/note/delete/126472/useless Del: bad code -- https://main.php.net/note/delete/126472/bad+code Del: spam -- https://main.php.net/note/delete/126472/spam Del: non-english -- https://main.php.net/note/delete/126472/non-english Del: in docs -- https://main.php.net/note/delete/126472/in+docs Del: other reasons-- https://main.php.net/note/delete/126472 Reject -- https://main.php.net/note/reject/126472 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217024) next »