3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Language: int { case English = 1; case SPANISH = 2; public static function getLanguageKey(string $language): int { $reflection = new \ReflectionEnum(Language::class); return $reflection->getCase($language)->getValue()->value; } public static function getLanguageName(int $languageKey): string { $reflection = new \ReflectionEnum(Language::class); $case = array_filter($reflection->getCases(), fn($enum) => $enum->getValue()->value === $languageKey); return $case[0]->getValue()->name; } } $input = 1; Language::getLanguageName($input); // 'English $input = 'English'; Language::getLanguageKey($input); // '1
Output for git.master, git.master_jit

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:
40.36 ms | 731 KiB | 4 Q