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.24, 8.3.0 - 8.3.12
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.30
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:
48.68 ms | 410 KiB | 5 Q