<?phpheader('Content-Type: text/html; charset=utf-8');class Yayin {private static $ornek;public static function ornekAl() {if (self::$ornek == null) {self::$ornek = new Yayin();}return self::$ornek;}protected function __construct(){foreach($_POST as $key => $value ){$this->$key = $value;}}public function __get($isim){if (!isSet($this->$isim)){$this->$isim= '';}}}$yayin = Yayin::ornekAl();$deger = $yayin->deger;$artis = $yayin->artis;if ($artis == null) {$artis = 1;}$deger += $artis;?>method="POST"Arttırılacak Değer: type="text" name="deger" value="<?php echo $deger;?>"Artış: type="text" name="artis" value="<?php echo $artis;?>"type="submit" value="Arttır"
Çıktısı öne çıkan görseldeki gibidir.