Create a class containing your 3 variables and returning an instance of the class. Example:
<?php class A { public $a; public $b; public $c; public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } } function a() { return new A("a", "b", "c"); } echo a()->a; echo a()->b; echo a()->c; ?>
Of course, the last 3 lines are not particularly efficient, because a() is called 3 times. Reasonable refactoring will result in these 3 lines being changed to:
$a = a(); echo $a->a; echo $a->b; echo $a->c;
Asaph
source share