3v4l.org

run code in 300+ PHP versions simultaneously
<?php class String {   /**    * Fast string templating.    * Uses a Twig-like syntax.    *    * @example    * echo String::render('Your IP is : {{ server.REMOTE_HOST }}',array('server' => $_SERVER));    *    * @author Stefano Azzolini <stefano.azzolini@caffeinalab.com>    * @access public    * @static    * @param mixed $t The text template    * @param mixed $v (default: null) The array of values exposed in template.    * @return string    */   public static function render($t,$v=null){     function _rh(&$f,&$v) {       static $m;$m?:$m=array();       if(isset($m[$f])) return $m[$f];       for($t=strtok($f,'.'),$q=isset($v[$t])?$v:'';         isset($q[$t])&&$t!==false;         $q=isset($q[$t])?$q[$t]:'',$t=strtok('.')        ); return $m[$f]=($t?'':$q);     }     $t = is_array($t)?'':$t; if(empty($v)) return $t;     for ($e=explode('{{',$t),$r=$e[$i=0];       isset($e[++$i]) && $ss=explode('}}',$e[$i]);       $r.=(strpos($q=trim($ss[0]),'.')!==false?       _rh($q,$v):(isset($v[$q])?$v[$q]:''))       .end($ss));return $r;   } } /* End of class */ echo String::render('My name is {{name}}, I\'m {{job.role}} at {{job.info.agency}}, {{job.place}}. [{{job.info.url}}].',[   'name' => 'Stefano',   'job' => [     'role' => 'CTO',     'place' => 'Italy',     'info' => [       'agency' => 'Caffeina',       'url' => 'http://caffeina.co',     ],   ], ]);
Output for 5.4.0 - 5.4.32
Parse error: syntax error, unexpected ' ' (T_STRING), expecting function (T_FUNCTION) in /in/GeQYD on line 5
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /in/GeQYD on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING, expecting T_FUNCTION in /in/GeQYD on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/GeQYD on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/GeQYD on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/GeQYD on line 5
Process exited with code 255.

preferences:
204.09 ms | 1395 KiB | 123 Q