3v4l.org

run code in 300+ PHP versions simultaneously
<?php $txt = "Text including variables to be replaced, such as {name}, {id}, {something} and {other}"; $vars = array( 'name' => 'name', 'id' => 'userid', 'something' => 'undefinedItem', ); $user = new stdClass(); $user->name = 'James Bond'; $user->userid = '007'; echo str_replace( array_map( function($item) { return '{'. $item .'}'; }, array_keys($vars) ), array_map( function($item) use ($user) { return isset($user->$item) ? $user->$item : 'undefined'; }, $vars ), $txt );
Output for git.master, git.master_jit, rfc.property-hooks
Text including variables to be replaced, such as James Bond, 007, undefined and {other}

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:
127.69 ms | 405 KiB | 5 Q