3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ public $id; function __construct($id) { $this->id = $id; } } class UserStorage extends SPLObjectStorage{ public function getHash($obj){ return $obj->id; } } $us = new UserStorage(); $user1 = new User(1); $user2 = new User(2); $us->attach($user1); $us->attach($user2); $me = new User(2); // the following would normally fail since they are two separate objects // but it works now with our extended getHash() var_dump($us->contains($me));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of UserStorage::getHash($obj) should either be compatible with SplObjectStorage::getHash(object $object): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/YnvsU on line 14 Fatal error: Uncaught RuntimeException: Hash needs to be a string in /in/YnvsU:23 Stack trace: #0 /in/YnvsU(23): SplObjectStorage->attach(Object(User)) #1 {main} thrown in /in/YnvsU on line 23
Process exited with code 255.

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:
36.88 ms | 402 KiB | 8 Q