3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { protected $my_var = 42; public function bar() { preg_replace_callback('/./', function($match) use ($this) { var_dump($this->my_var); }, 'a'); } } $fizz = new foo(); $fizz->bar();
Output for 5.3.0 - 5.3.20, 5.4.0 - 5.4.10
Fatal error: Cannot use $this as lexical variable in pXhUF on line 8
Process exited with code 255.

preferences:
174.83 ms | 1395 KiB | 39 Q