Http Post İsteklerine Erişim Sınıfı

PHP
38 lines
<?php
header('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;
?>
<html>
<body>
<form method="POST">
Arttırılacak Değer: <input type="text" name="deger" value="<?php echo $deger;?>"/>
<br/>Artış: <input type="text" name="artis" value="<?php echo $artis;?>"/>
<br/><input type="submit" value="Arttır"/>
</form>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Çıktısı öne çıkan görseldeki gibidir.