3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace WFPKSYS\System\Traits\Configuration; { trait SupportSystemConfiguration { protected $_supportSystemConfiguration; public function getSupportSystemConfiguration() : \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration { return $this->_supportSystemConfiguration; } public function setSupportSystemConfiguration( \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfiguration ) : void { $this->_supportSystemConfiguration = $supportSystemConfiguration; } } } namespace WFPKSYS\SupportSystem\Models\Configuration; { class SupportSystemConfiguration { private $_db_Name; public function __construct() {$this->setDb_Name( "MyTestDb" );} public function getDb_Name() : string { return $this->_db_Name; } public function setDb_Name( string $db_Name ) : void { $this->_db_Name = $db_Name; } } } namespace WFPKSYS\SupportSystem\Models; { class Foo { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\SupportSystem\Models; { class Bar { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig) {$this->setSupportSystemConfiguration( $supportSystemConfig );} public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\SupportSystem\Models; { class Fuzz { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig ) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function performCheck() : string { $objFoo = new \WFPKSYS\SupportSystem\Models\Foo( $this->getSupportSystemConfiguration() ); $objBar = new \WFPKSYS\SupportSystem\Models\Bar( $this->getSupportSystemConfiguration() ); $objFoo->displayCheck(); $objBar->displayCheck(); return "completed"; } } } $objSupportSystemConfiguration = new \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration(); $objFuzz = new \WFPKSYS\SupportSystem\Models\Fuzz( $objSupportSystemConfiguration ); echo $objFuzz->performCheck();
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
completed
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 completed
Output for 7.0.0 - 7.0.33
Fatal error: Uncaught TypeError: Return value of WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration::setDb_Name() must be an instance of WFPKSYS\SupportSystem\Models\Configuration\void, none returned in /in/5AcD7:30 Stack trace: #0 /in/5AcD7(25): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->setDb_Name('MyTestDb') #1 /in/5AcD7(95): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->__construct() #2 {main} thrown in /in/5AcD7 on line 30
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/5AcD7 on line 10
Process exited with code 255.

preferences:
228.45 ms | 401 KiB | 293 Q