3v4l.org

run code in 200+ PHP versions simultaneously
<?php interface iCrud { public function create($data); public function read(); public function update($data); public function delete(); } class User implements iCrud { private $_userId = NULL; private $_username = NULL; function __construct($data) { $this->_userId = uniqid(); $this->_username = $data['username']; } function create($data) { self::__construct($data); } function read() { return array('userId' => $this->_userId, 'username' => $this->_username); } function update($data) { $this->_username = $data['username']; } public function delete() { $this->_username = NULL; $this->_userId = NULL; } } // assignment $u = new User(['username' => 'potato']); $u->create(['username' => 'notPotato']); var_dump($u);
Output for 7.3.3
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101001ad" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.3.2
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101027b3" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.3.1
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101765" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.3.0
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101c6a" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.16
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101f7a" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.15
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101a6c" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.14
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101015eb" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.13
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610100115" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.12
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101011c5" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.11
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610102c7c" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.10
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c9761010160f" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.9
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610102587" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.8
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c9761010021a" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.7
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101015d4" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.6
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101564" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.5
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c9761010764d" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.4
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101019c3" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.3
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101aa7" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.2
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610101cfa" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.1
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101016ad" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.2.0
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101000da" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.1.27
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c976101020d0" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.1.26
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c97610100f22" ["_username":"User":private]=> string(9) "notPotato" }
Output for 7.1.25
object(User)#1 (2) { ["_userId":"User":private]=> string(13) "5c9761010154f" ["_username":"User":private]=> string(9) "notPotato" }