note 124417 added to function.call-user-func-array

From: Date: Thu, 21 Nov 2019 00:10:41 +0000
Subject: note 124417 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-213155@lists.php.net to get a copy of this message
<?php namespace Foobar; class Foo { public $email; public $name; public $age; public function setEmail($email) { $this->email = $email; } public function setName($name) { $this->name = $name; } public function setAge($age) { $this->age = $age; } } function getFields() { return [ "age" => 112, "email" => "lol@lol.fr", "name" => "lol" ]; } $foo = new Foo(); $callables = ["email" => $email,"name" => $name,"age" => $age] = getFields(); foreach ($callables as $func => $value) { call_user_func(array($foo,sprintf("set%s",ucfirst($func))),$value)); } var_dump($foo); ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 89.2.147.18) ---- Manual Page -- http://php.net/manual/en/function.call-user-func-array.php Edit -- https://master.php.net/note/edit/124417 Del: integrated -- https://master.php.net/note/delete/124417/integrated Del: useless -- https://master.php.net/note/delete/124417/useless Del: bad code -- https://master.php.net/note/delete/124417/bad+code Del: spam -- https://master.php.net/note/delete/124417/spam Del: non-english -- https://master.php.net/note/delete/124417/non-english Del: in docs -- https://master.php.net/note/delete/124417/in+docs Del: other reasons-- https://master.php.net/note/delete/124417 Reject -- https://master.php.net/note/reject/124417 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213155) next »