myclass.php içeriği
<?php
class Hesapla{
public $a;
public $b;
function Topla(){
return $this->a+$this->b;
}
function Cikart(){
return $this->a-$this->b;
}
function Carp(){
return $this->a*$this->b;
}
function Bol(){
return $this->a/$this->b;
}
}
?>
index.php php kod içeriği
<?php
include "myclass.php";
header('http-equiv=Content-Type content=text/html; charset=utf-8');
$hesapla=new Hesapla();
if(isset($_POST["hesapla"])==TRUE){
$hesapla->a=$_POST["deger1"];
$hesapla->b=$_POST["deger2"];
$islem=$_POST["islem"];
}
else{
$deger1=1;
$deger2=1;
$islem="a";
}
switch ($islem){
case "topla":
echo "Sonuç: ".$hesapla->Topla();
break;
case "cikart":
echo "Sonuç: ".$hesapla->Cikart();
break;
case "carp":
echo "Sonuç: ".$hesapla->Carp();
break;
case "bol":
echo "Sonuç: ".$hesapla->Bol();
break;
default:
echo "Hata";
break;
}
?>
index.php
myclass.php
Hiç yorum yok:
Yorum Gönder