3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class address { public $street1 = " abc "; public $street2 = " abc "; public $city = " abc "; public $state = " abc "; public $zip = " abc "; public function setProperty1($newval) { $this->street1 = $newval; } public function getProperty1() { return $this->street1 . "<br />"; } public function setProperty2($newval) { $this->street2 = $newval; } public function getProperty2() { return $this->street2 . "<br />"; } public function setProperty3($newval) { $this->city = $newval; } public function getProperty3() { return $this->city . "<br />"; } public function setProperty4($newval) { $this->state = $newval; } public function getProperty4() { return $this->state . "<br />"; } public function setProperty5($newval) { $this->zip = $newval; } public function getProperty5() { return $this->zip . "<br />"; } } // Create objects $obj1 = new address; $obj2 = new address; $obj3 = new address; $obj4 = new address; // Set new values for all objects $obj1->setProperty1("street11"); $obj1->setProperty2("street21"); $obj1->setProperty3("city1"); $obj1->setProperty4("state1"); $obj1->setProperty5("zip1"); $obj2->setProperty1("street12"); $obj2->setProperty2("street22"); $obj2->setProperty3("city2"); $obj2->setProperty4("state2"); $obj2->setProperty5("zip2"); $obj3->setProperty1("street13"); $obj3->setProperty2("street23"); $obj3->setProperty3("city3"); $obj3->setProperty4("state3"); $obj3->setProperty5("zip3"); $obj4->setProperty1("street14"); $obj4->setProperty2("street24"); $obj4->setProperty3("city4"); $obj4->setProperty4("state4"); $obj4->setProperty5("zip4"); echo "\n"; // Output echo $obj1->getProperty1(); echo $obj1->getProperty2(); echo $obj1->getProperty3(); echo $obj1->getProperty4(); echo $obj1->getProperty5(); echo "\n"; echo $obj2->getProperty1(); echo $obj2->getProperty2(); echo $obj2->getProperty3(); echo $obj2->getProperty4(); echo $obj2->getProperty5(); echo "\n"; echo $obj3->getProperty1(); echo $obj3->getProperty2(); echo $obj3->getProperty3(); echo $obj3->getProperty4(); echo $obj3->getProperty5(); echo "\n"; echo $obj4->getProperty1(); echo $obj4->getProperty2(); echo $obj4->getProperty3(); echo $obj4->getProperty4(); echo $obj4->getProperty5(); echo "\n"; ?>
based on 0Utoh
Output for 5.5.0 - 7.2.6
street11<br />street21<br />city1<br />state1<br />zip1<br /> street12<br />street22<br />city2<br />state2<br />zip2<br /> street13<br />street23<br />city3<br />state3<br />zip3<br /> street14<br />street24<br />city4<br />state4<br />zip4<br />