3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class Email { public function __construct(public string $emailString){} public function __toString() {return trim($this->emailString);} } readonly class ValidEmail extends Email {} function validateEmail(Email $email): ValidEmail {return new ValidEmail($email);} function saveToDatabase(ValidEmail $email) {return 'Saved succesfully';} $email = new Email('vasya@pupkin.com'); $validatedEmail = validateEmail($email); var_dump(saveToDatabase($validatedEmail)); var_dump(saveToDatabase($email));
Output for git.master_jit, git.master
string(17) "Saved succesfully" Fatal error: Uncaught TypeError: saveToDatabase(): Argument #1 ($email) must be of type ValidEmail, Email given, called in /in/hkTDp on line 17 and defined in /in/hkTDp:11 Stack trace: #0 /in/hkTDp(17): saveToDatabase(Object(Email)) #1 {main} thrown in /in/hkTDp on line 11
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:
44.26 ms | 405 KiB | 5 Q