3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class WebASM { private $_input; private $_val; private $_0 = 0; private $_1 = 0; private $_2 = 0; private $_3 = 0; private $_4 = 0; private $_5 = 0; private $_6 = 0; private $_7 = 0; public function __construct($code) { $this->_0 = $code; unset($code); if(!is_string($this->_0)) { $this->_0 = 0; return 1; } if(preg_match('#^file\:#', $this->_0)) { $this->_0 = preg_replace('#^file\:#', '', $this->_0); if(file_exists($this->_0)) { $this->_0 = file_get_contents($this->_0); } else { $this->_0 = 0; return 1; } } $this->_0 = preg_replace_callback('#(.*):#', function ($matches) { if(is_numeric($matches[1])) { return 'a'.$matches[0]; } else { return '//'.$matches[0]; } }, $this->_0); $this->_0 = preg_replace('#pri?nt (.*)#', 'echo(\$this->_$1);', $this->_0); $this->_0 = preg_replace('#set ([0-7]) ([0-9]{1,256})#U', '\$this->_$1 = $2;', $this->_0); $this->_0 = preg_replace('#copyto ([0-7])#', '\$this->_$1 = \$this->_val;', $this->_0); $this->_0 = preg_replace('#copyfrom ([0-7])#', '\$this->_val = \$this->_$1;', $this->_0); //$this->_0 = preg_replace('#pro?mpt (str|int) ([0-9]{256})#', 'echo($1);', $this->_0); $this->_0 = preg_replace('#add ([0-7])#', '\$this->_val = \$this->_val + \$this->_$1;', $this->_0); $this->_0 = preg_replace('#sub ([0-7])#', '\$this->_val = \$this->_val - \$this->_$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256}) if ([0-7]) ([0-9]{1,256})#', 'if(\$this->_$2 == $3) goto a$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256}) if ([0-9]{1,256})#', 'if(\$this->_val == $2) goto a$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256})#', 'goto a$1;', $this->_0); $this->_0 = preg_replace('#(die|re?tu?rn|exit)#', 'return 0;', $this->_0); $this->_0 = '$c = function () {'.$this->_0.'return 1;};$x=$c();if($x!=0)echo("An error has occured.");'; eval($this->_0); } } $code = <<<WebASM set 0 1 set 1 1 copyfrom 0 0: add 1 jump 1 if 3 jump 0 1: copyto 0 print 0 lol: print 1 WebASM; $asm = new WebASM($code);
based on vB1mt
Output for 5.4.9 - 7.2.0
31An error has occured.
Output for 5.3.19 - 5.3.29
Fatal error: Using $this when not in object context in /in/ptomd(50) : eval()'d code on line 1
Process exited with code 255.