Advertisement
ujiajah1

Oop_basic.php

Oct 27th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. class ngopi{
  2.     public $kopi;
  3.     public $udud;
  4.     public $nikmat=true;
  5. public function __construct($kopi,$udud){
  6.     $this->kopi=$kopi;
  7.     $this->roko=$udud;
  8. }
  9. public function samsu_dua_mantap(){
  10.     return "Kopi = $this->kopi\n"."Roko = $this->roko";
  11. }
  12. }
  13. $bongkar=new ngopi("Kopi Bongkar","Samsul dua batang mantap");
  14. $nyoh = new ngopi("Kopi Tubruk","Djarum Coklat");
  15. $nyoh->nikmat=false;
  16. echo $bongkar->samsu_dua_mantap();
  17.  
  18. class Handphone{
  19.   public $kamera;
  20.   public $tahun;
  21.   public $layar_sentuh=true;
  22.  
  23.   public function __construct($kamera,$tahun){
  24.     $this->kamera=$kamera;
  25.     $this->tahun=$tahun;
  26.   }
  27.   public function ambil_photo(){
  28.     return "$this->kamera \njepret..!!";
  29.   }
  30. }
  31.  
  32. $canggih = new Handphone("Kamera: 8 Megapixels","Tahun : 2013");
  33. $jadul = new Handphone("Kamera: 2 Megapixels","Tahun : 2012");
  34. $jadul->layar_sentuh=false;
  35. echo $canggih->ambil_photo();
  36.  
  37. <?
  38. class Kucing {
  39.   public $lucu = true;
  40.   public $warna;
  41.  
  42.   public function __construct($warna) {
  43.     $this->warna= $warna;
  44.   }
  45.   public function meong(){
  46.     return "Meoing..!!";
  47. }
  48.   public function menyapa(){
  49.     return "Hai, saya si $this->warna";
  50.   }
  51. }
  52.   $putih=new kucing("putih");
  53.   $hitam=new kucing("hitam");
  54. echo $putih->menyapa()."\n".$hitam->menyapa()."\n";
  55. echo $hitam->meong();
  56. ?>
  57.  
  58. <?
  59. class Orang {
  60.     public $lokasi = "codesaya";
  61.     public $nama;
  62.     public $umur;
  63.  
  64.     public function __construct($nama, $umur) {
  65.         $this->nama = $nama;
  66.         $this->umur = $umur;
  67.     }
  68.  
  69.     // ciptakan metode menyapa() di bawah
  70.   public function menyapa(){
  71.     return "Hi, saya $this->nama umur saya $this->umur.";
  72. }
  73. }
  74. $saya = new Orang("Rasmus Lerdorf", 44);
  75.  
  76. // panggil dan cetak metode menyapa() $saya di bawah
  77.   echo $saya->menyapa();
  78.  
  79. ?>
  80.  
  81. class Orang {
  82.   public $lokasi = "codesaya";
  83.   public $nama;
  84.   public $umur;
  85.  
  86.   // berikan __construct di bawah
  87.   public function __construct($nama,$umur){
  88.     $this->nama=$nama;
  89.     $this->umur=$umur;
  90. }
  91. }
  92. // Ubah baris dibawah dengan memberi
  93. //  dua parameter di antara tanda kurung
  94. $guru = new Orang("Soleh ",30);
  95. $murid = new Orang("Puji ",29);
  96.  
  97. // akses properti dari $guru & murid di bawah
  98.   echo $guru->nama.$guru->umur."\n";
  99.   echo $murid->nama.$murid->umur;
  100.  
  101. <!doctype html>
  102. <html>
  103. <head>
  104. <title>wewwww</title>
  105. <link rel="shortcut icon" href="logo3.png">
  106. </head>
  107. <body>
  108. <div id="topologi">
  109. <?php
  110. class topology{
  111. public $network;
  112. public $ip_address;
  113. public $proxy=true;
  114.  
  115. public function __construct($network,$ip_address){
  116. $this->network = $network;
  117. $this->ip_address = $ip_address;
  118. }
  119.  
  120. public function tproxy(){
  121. return "Network   = ".$this->network."<br/>"."ip_address = ".$this->ip_address;
  122. }
  123. }
  124.  
  125. $tunel = new topology("Yes Via Proxy","10.0.40.254");
  126. $transparent = new topology("No Proxy detect","118.220.222.234");
  127. $client_side = $tunel->tproxy();
  128. $tunel->proxy = false;
  129. echo $client_side."<br/><br/>";
  130. for($abc=1;$abc<50;$abc++){
  131. echo "*";
  132. }
  133. echo "<br/><br/>";
  134.  
  135. if($client_side == $tunel->tproxy()){
  136. echo 'Tproxy Topology'."<br/>".
  137. '<img src=" http://1.bp.blogspot.com/-Nk6LcVPp1qg/VYe1No9OlTI/AAAAAAAAAho/45EtnMJaLiY/s1600/Topologi%2Bjaringan.jpg" width="500" height="350"/>';
  138. }
  139. elseif($client_side !== $tunel->tproxy()){
  140. echo "No Proxy Detect";
  141. }
  142. ?>
  143. </div>
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement