3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface OwnerInterface { public function setData($data); public function getOwnerId($name); public function getOwner($ownerId); } interface AssetInterface { public function setData($data); public function getAssetId($ownerId); public function getAsset($assetId); } class Asset implements AssetInterface, OwnerInterface { protected $assetId; // string or int? DB autogen? protected $assetType; // string protected $assetSubType; protected $ownerId; // protected $owner; // object protected $beneficiary; // string public function setData($data) { } public function getAssetId($ownerId) { } public function getAsset($assetId) { return $this; } public function getAssetType($assetId) { } public function getAssetSubType($assetId) { } public function getOwnerId($name) { } public function getOwner($ownerId) { return $this->owner; // Owner object; I don't think this is the owner object } public function setAssetId($assetId) { } public function setAsset($assetId) { } public function setAssetType($assetId) { } public function setAssetSubType($assetId, $subType) { $this->assetSubType=$subType; } public function setOwnerId($ownerId) { } } ////////////////////////////////////////////////////////// $asset=new Asset(); $assetId="A0001"; $assetType="BUILDING"; $assetSubType="Gas Station"; $ownerId="Current Owner Id"; $asset->$assetId=$assetId; // string or int? DB autogen? $asset->$assetType=$assetType; // string $asset->$ownerId=$ownerId; // $asset->$assetSubType=$assetSubType; // string var_dump($asset);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Creation of dynamic property Asset::$A0001 is deprecated in /in/okgta on line 95 Deprecated: Creation of dynamic property Asset::$BUILDING is deprecated in /in/okgta on line 96 Deprecated: Creation of dynamic property Asset::$Current Owner Id is deprecated in /in/okgta on line 97 Deprecated: Creation of dynamic property Asset::$Gas Station is deprecated in /in/okgta on line 99 object(Asset)#1 (10) { ["assetId":protected]=> NULL ["assetType":protected]=> NULL ["assetSubType":protected]=> NULL ["ownerId":protected]=> NULL ["owner":protected]=> NULL ["beneficiary":protected]=> NULL ["A0001"]=> string(5) "A0001" ["BUILDING"]=> string(8) "BUILDING" ["Current Owner Id"]=> string(16) "Current Owner Id" ["Gas Station"]=> string(11) "Gas Station" }
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 Deprecated: Creation of dynamic property Asset::$A0001 is deprecated in /in/okgta on line 95 Deprecated: Creation of dynamic property Asset::$BUILDING is deprecated in /in/okgta on line 96 Deprecated: Creation of dynamic property Asset::$Current Owner Id is deprecated in /in/okgta on line 97 Deprecated: Creation of dynamic property Asset::$Gas Station is deprecated in /in/okgta on line 99 object(Asset)#1 (10) { ["assetId":protected]=> NULL ["assetType":protected]=> NULL ["assetSubType":protected]=> NULL ["ownerId":protected]=> NULL ["owner":protected]=> NULL ["beneficiary":protected]=> NULL ["A0001"]=> string(5) "A0001" ["BUILDING"]=> string(8) "BUILDING" ["Current Owner Id"]=> string(16) "Current Owner Id" ["Gas Station"]=> string(11) "Gas Station" }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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
object(Asset)#1 (10) { ["assetId":protected]=> NULL ["assetType":protected]=> NULL ["assetSubType":protected]=> NULL ["ownerId":protected]=> NULL ["owner":protected]=> NULL ["beneficiary":protected]=> NULL ["A0001"]=> string(5) "A0001" ["BUILDING"]=> string(8) "BUILDING" ["Current Owner Id"]=> string(16) "Current Owner Id" ["Gas Station"]=> string(11) "Gas Station" }

preferences:
205.18 ms | 404 KiB | 287 Q