3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Basic{ public function sayHello(){ echo 'Hello world!'; } } trait TraitMethod{ public function sayHello($name){ echo 'Hello! My name is '.$name; } } class TestC extends Basic{ use TraitMethod; public function sayHello($name, $lastname){ parent::sayHello(); TraitMethod::sayHello($name); echo ' '.$lastname; } } $objTestC = new TestC(); $objTestC->sayHello("Nikodem", "Niedowiarek");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Declaration of TestC::sayHello($name, $lastname) must be compatible with Basic::sayHello() in /in/p7T7Q on line 18
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of TestC::sayHello($name, $lastname) should be compatible with Basic::sayHello() in /in/p7T7Q on line 18 Hello world! Deprecated: Non-static method TraitMethod::sayHello() should not be called statically in /in/p7T7Q on line 20 Hello! My name is Nikodem Niedowiarek
Output for 7.3.32 - 7.3.33
Warning: Declaration of TestC::sayHello($name, $lastname) should be compatible with Basic::sayHello() in /in/p7T7Q on line 15 Hello world!Hello! My name is Nikodem Niedowiarek
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Warning: Declaration of TestC::sayHello($name, $lastname) should be compatible with Basic::sayHello() in /in/p7T7Q on line 15 Hello world! Deprecated: Non-static method TraitMethod::sayHello() should not be called statically in /in/p7T7Q on line 20 Hello! My name is Nikodem Niedowiarek
Output for 5.6.8 - 5.6.28
Strict Standards: Declaration of TestC::sayHello() should be compatible with Basic::sayHello() in /in/p7T7Q on line 15 Hello world! Deprecated: Non-static method TraitMethod::sayHello() should not be called statically, assuming $this from incompatible context in /in/p7T7Q on line 20 Hello! My name is Nikodem Niedowiarek
Output for 5.5.24 - 5.5.35
Strict Standards: Declaration of TestC::sayHello() should be compatible with Basic::sayHello() in /in/p7T7Q on line 15 Hello world! Strict Standards: Non-static method TraitMethod::sayHello() should not be called statically, assuming $this from incompatible context in /in/p7T7Q on line 20 Hello! My name is Nikodem Niedowiarek

preferences:
158.24 ms | 402 KiB | 198 Q