3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $template = "<html><head><title>{{head}}</title></head><body>{{body}}</body></html>"; $vars = explode(',', '{{'.implode('}},{{', array_keys($this->vars)).'}}'); $output = str_replace($vars, $this->vars, $template); echo $output;
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/6Wgr3:4 Stack trace: #0 {main} thrown in /in/6Wgr3 on line 4
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: $this is null in /in/6Wgr3:4 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: $this is null in /in/6Wgr3 on line 4
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/6Wgr3 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Undefined variable: this in /in/6Wgr3 on line 4 Warning: array_keys(): The first argument should be an array in /in/6Wgr3 on line 4 Warning: implode(): Bad arguments. in /in/6Wgr3 on line 4 Notice: Undefined variable: this in /in/6Wgr3 on line 6 <html><head><title>{{head}}</title></head><body>{{body}}</body></html>
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: this in /in/6Wgr3 on line 4 Warning: array_keys() [http://www.php.net/function.array-keys]: The first argument should be an array in /in/6Wgr3 on line 4 Warning: implode() [http://www.php.net/function.implode]: Bad arguments. in /in/6Wgr3 on line 4 Notice: Undefined variable: this in /in/6Wgr3 on line 6 <html><head><title>{{head}}</title></head><body>{{body}}</body></html>