3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $a = 'protected_prop'; private $b = 'private_prop'; function out(){ echo $this->a.' '.$this->b."<br/>"; } } $F = new Foo(); $F->out(); $F = serialize($F); $F = str_replace('protected_prop','new_protected_prop',$F); $F = str_replace('private_prop','new_private_prop',$F); $F = preg_replace_callback ( '!s:(\d+):"(.*?)";!', function($match) { return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; },$F ); $F = unserialize($F); $F->out();

preferences:
47.46 ms | 402 KiB | 5 Q