3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StringHelper { public function interpolate($str, array $context = [], $asIs = false) { $replace = []; foreach ($context as $key => $val) { if ($asIs) { $replace[$key] = $val; } else { $replace['{{' . $key . '}}'] = $val; } } return strtr($str, $replace); } } class CacheKeysDict { protected static $stringHelper = null; const BOT_ACTIVITY_MESSAGES = 'bot_activity_messages'; const PROFILE = 'profile_{{id}}'; public static function prepareKey($key, array $context = []) { return self::getStringHelper()->interpolate($key, $context); } public static function getStringHelper() { if (is_null(self::$stringHelper)) { self::$stringHelper = new StringHelper; } return self::$stringHelper; } } var_dump([ CacheKeysDict::BOT_ACTIVITY_MESSAGES, CacheKeysDict::prepareKey(CacheKeysDict::BOT_ACTIVITY_MESSAGES), CacheKeysDict::prepareKey(CacheKeysDict::PROFILE, ['id' => 503]), ]);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> string(21) "bot_activity_messages" [1]=> string(21) "bot_activity_messages" [2]=> string(11) "profile_503" }

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.18 ms | 401 KiB | 8 Q