note 129934 added to language.types.callable

From: Date: Tue, 24 Dec 2024 19:52:42 +0000
Subject: note 129934 added to language.types.callable
Groups: php.notes 
Request: Send a blank email to php-notes+get-221743@lists.php.net to get a copy of this message
Using callables variables and properties in PHP 7.4 and higher: <?php // fn is a variable of the type "callable" $fn=function($a1,$a2) { return $a1+$a2; }; // calling it echo $fn(10,20); class ExampleClass { public $callable; public function callCalable() { // calling a callable inside a method echo ($this->callable)(10,20); } } $instance=new ExampleClass(); $instance->callable=function($a1,$a2) { return $a1+$a2; }; $instance->callCalable(); // calling a calable echo ($instance->callable)(10,20); ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 190.100.245.177) ---- Manual Page -- https://php.net/manual/en/language.types.callable.php Edit -- https://main.php.net/note/edit/129934 Del: integrated -- https://main.php.net/note/delete/129934/integrated Del: useless -- https://main.php.net/note/delete/129934/useless Del: bad code -- https://main.php.net/note/delete/129934/bad+code Del: spam -- https://main.php.net/note/delete/129934/spam Del: non-english -- https://main.php.net/note/delete/129934/non-english Del: in docs -- https://main.php.net/note/delete/129934/in+docs Del: other reasons-- https://main.php.net/note/delete/129934 Reject -- https://main.php.net/note/reject/129934 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221743) next »