Input Data : PWD


Index.php

<!DOCTYPE html>
<html>
<head>
                <title>BIODATA</title>
</head>
<body>

<form action="index.php" method="POST">
                NAMA = <input type="text" name="nama"></br>
                ALAMAT = <input type="text" name="alamat"></br>
                <input type="submit" value="OK">



               
</form>


<table>
                                <tr>
                                                <td>NAMA</td>
                                                <td>ALAMAT</td>
                                </tr>
                                <tr>
                                                <td><? echo "$_POST['nama']";?></td>
                                                <td><? echo "$_POST['alamat']";?></td>
                                </tr>

</table>



</body>
</html>


Tambah.php

<?php
   class jualbeli{
        var $harga = "7000";
        protected $nego = "5000";
        private $kondisi = "baru";


        public function harganya(){
             return "harganya adalah $this->harga";
      }

      public function negosiasi(){
             return "harga nego adalah $this->nego";
      }

      public function kondisinya(){
                                return "kondisi $this->kondisi";
      }



}


  class barter extends jualbeli {
                                public function negosiasi1(){
        return "harga nego dari jual beli $this->nego";
    }

}


$jual = new jualbeli();
$barter = new barter();

echo $jual->harganya()."<br>";
echo $jual->negosiasi()."<br>";
echo $jual->kondisinya()."<br>";


echo $barter->negosiasi1();



?>


Class/index.php
<?php

class BangunRuang{
                var $p;
                private $l;
                protected $luas;
                var $keliling;

                function setl($l){
                                $this->l = $l;
                }

                function setp($p){
                                $this->p = $p;
                }

                function getLuas(){
                                return $this->p*$this->l;
                }

                function getKeliling(){
                                return 2*($this->p+$this->l);
                }
}

class Kubus extends BangunRuang{
                var $t;

                function sett($t){
                                $this->t = $t;
                }

                function getVolume(){
                                return $this->p*$this->l*$this->t;
                }
}

$persegi = new BangunRuang();
$PPanjang = new BangunRuang();
$Kubus = new Kubus();

$persegi->setp(10);
$persegi->setl(10);
echo "Luas Persegi = ".$persegi->getLuas()."<br />";
echo "Keliling Persegi = ".$persegi->getKeliling();

?>


Previous
Next Post »

Translate