3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait first_trait { function first_function() { echo "From First Trait\n"; } } trait second_trait { use first_trait { first_trait::first_function as second_function; second_function insteadof first_function; } function first_function() { echo "From Second Trait\n"; } } class first_class { use second_trait; } $obj = new first_class(); // Output: From Second Trait $obj->first_function(); // Output: From First Trait $obj->second_function();
Output for 5.4.0 - 5.4.11
Parse error: syntax error, unexpected 'insteadof' (T_INSTEADOF), expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /in/sUash on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.21
Parse error: syntax error, unexpected T_STRING in /in/sUash on line 2
Process exited with code 255.

preferences:
164.38 ms | 1395 KiB | 41 Q