3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserService { public function userFactory() { $user=new User(); $user->id='test_id'; return $user; } } class Conversation { public $participants=array(); public function getParticipants() { return $this->participants; } } class User { public $id; } $u1=new User(); $u2=new User(); $conversation=new Conversation(); $conversation->participants[]=$u1; $conversation->participants[]=$u2; $userService=new UserService(); foreach($conversation->getParticipants() as &$participant) { $participant=$userService->userFactory(); } print_r($conversation);
Output for git.master, git.master_jit, rfc.property-hooks
Conversation Object ( [participants] => Array ( [0] => User Object ( [id] => ) [1] => User Object ( [id] => ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
28.76 ms | 402 KiB | 8 Q