3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class cls { protected $m_str = ''; function __construct( string & $str ) { $this->m_str = & $str; $this->m_str = 'first change'; $this->method( ); } protected function method( ) { $this->m_str = 'second change'; } } $str = 'unchanged'; $obj = new cls( $str ); echo "<br> str = $str";
Output for hhvm-3.15.4, 7.0.0 - 7.3.0rc3
<br> str = second change
Output for 5.6.0 - 5.6.30
Catchable fatal error: Argument 1 passed to cls::__construct() must be an instance of string, string given, called in /in/GpcS2 on line 20 and defined in /in/GpcS2 on line 7
Process exited with code 255.