note 117504 added to functions.anonymous

From: Date: Fri, 19 Jun 2015 21:48:06 +0000
Subject: note 117504 added to functions.anonymous
Groups: php.notes 
Request: Send a blank email to php-notes+get-202908@lists.php.net to get a copy of this message
<?php /* (string) $name Name of the function that you will add to class. Usage : $Foo->add(function(){},$name); This will add a public function in Foo Class. */ class Foo { public function add($func,$name) { $this->{$name} = $func; } public function __call($func,$arguments){ call_user_func_array($this->{$func}, $arguments); } } $Foo = new Foo(); $Foo->add(function(){ echo "Hello World"; },"helloWorldFunction"); $Foo->add(function($parameterone){ echo $parameterone; },"exampleFunction"); $Foo->helloWorldFunction(); /*Output : Hello World*/ $Foo->exampleFunction("Hello PHP"); /*Output : Hello PHP*/ ?> ---- Server IP: 72.52.91.14 Probable Submitter: 88.228.54.105 ---- Manual Page -- http://php.net/manual/en/functions.anonymous.php Edit -- https://master.php.net/note/edit/117504 Del: integrated -- https://master.php.net/note/delete/117504/integrated Del: useless -- https://master.php.net/note/delete/117504/useless Del: bad code -- https://master.php.net/note/delete/117504/bad+code Del: spam -- https://master.php.net/note/delete/117504/spam Del: non-english -- https://master.php.net/note/delete/117504/non-english Del: in docs -- https://master.php.net/note/delete/117504/in+docs Del: other reasons-- https://master.php.net/note/delete/117504 Reject -- https://master.php.net/note/reject/117504 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202908) next »