PHP ကျူတိုရီရယ်

PHP ပင်မစာမျက်နှာ PHP မိတ်ဆက် PHP ထည့်သွင်းပါ။ PHP Syntax PHP မှတ်ချက်များ PHP Variables များ PHP Echo / Print PHP Data အမျိုးအစားများ PHP စာတန်းများ PHP နံပါတ်များ PHP သင်္ချာ PHP Constants PHP Operator များ PHP If...Else...Elseif PHP Switch PHP Loops PHP လုပ်ဆောင်ချက်များ PHP Arrays PHP Superglobals PHP RegEx

PHP Forms

PHP Form ကိုင်တွယ်ခြင်း။ PHP Form Validation PHP Form လိုအပ်ပါသည်။ PHP Form URL/E-mail PHP Form ပြီးပါပြီ။

PHP အဆင့်မြင့်

PHP နေ့စွဲနှင့် အချိန် PHP ပါဝင်ပါတယ်။ PHP ဖိုင်ကိုင်တွယ်ခြင်း PHP ဖိုင်ကို ဖွင့်/ဖတ်ပါ။ PHP ဖိုင်ကို ဖန်တီး/ရေးပါ။ PHP ဖိုင်ကို တင်ခြင်း။ PHP Cookies PHP စက်ရှင်များ PHP Filters PHP Filters Advanced PHP ပြန်ခေါ်ခြင်းလုပ်ဆောင်ချက်များ PHP JSON PHP ခြွင်းချက်

PHP OOP

PHP OOP ဆိုတာဘာလဲ PHP အတန်းများ/အရာဝတ္ထုများ PHP Constructor PHP Destructor PHP Access Modifiers PHP Inheritance PHP Constants PHP Abstract အတန်းများ PHP မျက်နှာပြင်များ PHP လက္ခဏာများ PHP Static Methods PHP Static Properties PHP Namespaces PHP Iterables

MySQL ဒေတာဘေ့စ်

MySQL ဒေတာဘေ့စ် MySQL ချိတ်ဆက်မှု MySQL သည် DB ကိုဖန်တီးပါ။ MySQL ဇယားဖန်တီးပါ။ MySQL သည် Data ကိုထည့်သွင်းပါ။ MySQL နောက်ဆုံး ID ကိုရယူပါ။ MySQL တွင် Multiple ထည့်သွင်းပါ။ MySQL ပြင်ဆင်ထားသည်။ MySQL Data ကို ရွေးပါ။ MySQL ဘယ်မှာလဲ။ MySQL Order By MySQL က Data တွေကို ဖျက်လိုက်ပါ။ MySQL အပ်ဒိတ်ဒေတာ MySQL ကန့်သတ်ဒေတာ

PHP XML

PHP XML ပါဆာများ PHP SimpleXML Parser PHP SimpleXML - ရယူပါ။ PHP XML Expat PHP XML DOM

PHP - AJAX

AJAX နိဒါန်း AJAX PHP AJAX ဒေတာဘေ့စ် AJAX XML AJAX တိုက်ရိုက်ရှာဖွေမှု AJAX စစ်တမ်း

PHP ဥပမာများ

PHP ဥပမာများ PHP Compiler PHP Quiz PHP လေ့ကျင့်ခန်းများ PHP Certificate

PHP အ ကိုးအကား

PHP ခြုံငုံသုံးသပ်ချက် PHP Array PHP ပြက္ခဒိန် PHP နေ့စွဲ PHP လမ်းညွှန် PHP အမှား PHP ခြွင်းချက် PHP ဖိုင်စနစ် PHP Filter PHP FTP PHP JSON PHP သော့ချက်စာလုံးများ PHP Libxml PHP Mail PHP သင်္ချာ PHP ထွေ PHP MySQLi PHP ကွန်ရက် PHP Output Control PHP RegEx PHP SimpleXML PHP Stream PHP String PHP Variable ကိုင်တွယ်ခြင်း။ PHP XML Parser PHP Zip PHP အချိန်ဇုန်များ

PHP OOP - အမွေဆက်ခံခြင်း။


PHP - Inheritance ဆိုတာဘာလဲ။

OOP inheritance = အတန်းတစ်ခုသည် အခြားအတန်းမှဆင်းသက်လာသောအခါ။

ကလေးအတန်းအစားသည် မိဘအတန်းအစားထံမှ အများသူငှာ ကာကွယ်ထားသော ဂုဏ်သတ္တိများနှင့် နည်းလမ်းအားလုံးကို အမွေဆက်ခံပါမည်။ ထို့အပြင်၎င်းသည်၎င်း၏ကိုယ်ပိုင်ဂုဏ်သတ္တိများနှင့်နည်းလမ်းများရှိသည်။

extends သော့ချက်စာလုံး ကို အသုံးပြု၍ အမွေဆက်ခံထားသော အတန်းကို သတ်မှတ်သည် ။

ဥပမာတစ်ခုကိုကြည့်ရအောင်။

ဥပမာ

<?php
class Fruit {
  public $name;
  public $color;
  public function __construct($name, $color) {
    $this->name = $name;
    $this->color = $color;
  }
  public function intro() {
    echo "The fruit is {$this->name} and the color is {$this->color}.";
  }
}

// Strawberry is inherited from Fruit
class Strawberry extends Fruit {
  public function message() {
    echo "Am I a fruit or a berry? ";
  }
}
$strawberry = new Strawberry("Strawberry", "red");
$strawberry->message();
$strawberry->intro();
?>

နမူနာရှင်းပြထားပါတယ်။

Strawberry class သည် Fruit class မှ ဆင်းသက်လာသည်။

ဆိုလိုသည်မှာ Strawberry class သည် public $name နှင့် $color properties အပြင် public __construct() နှင့် intro() method ကို အမွေဆက်ခံရသောကြောင့် Fruit class မှ သုံးနိုင်သည်။

စတော်ဘယ်ရီအတန်းတွင်လည်း ၎င်း၏ကိုယ်ပိုင်နည်းလမ်း ရှိသည်- message()။



PHP - Inheritance နှင့် Protected Access Modifier

ယခင်အခန်း protectedတွင် ကျွန်ုပ်တို့သည် အတန်းတွင်းရှိ ဂုဏ်သတ္တိများ သို့မဟုတ် နည်းလမ်းများကို သင်ယူနိုင်ပြီး ထိုအတန်းမှ ဆင်းသက်လာသော အတန်းများအလိုက် ကျွန်ုပ်တို့ လေ့လာခဲ့သည်။ ဘာကိုဆိုလိုတာလဲ?

ဥပမာတစ်ခုကိုကြည့်ရအောင်။

ဥပမာ

<?php
class Fruit {
  public $name;
  public $color;
  public function __construct($name, $color) {
    $this->name = $name;
    $this->color = $color;
  }
  protected function intro() {
    echo "The fruit is {$this->name} and the color is {$this->color}.";
  }
}

class Strawberry extends Fruit {
  public function message() {
    echo "Am I a fruit or a berry? ";
  }
}

// Try to call all three methods from outside class
$strawberry = new Strawberry("Strawberry", "red");  // OK. __construct() is public
$strawberry->message(); // OK. message() is public
$strawberry->intro(); // ERROR. intro() is protected
?>

အထက်ဖော်ပြပါ ဥပမာ protected တွင် အတန်းပြင်ပမှ method (intro()) ကို ခေါ်ရန် ကြိုးစားပါက error ရရှိမည်ကို ကျွန်ုပ်တို့တွေ့မြင်ရပါသည်။ public နည်းလမ်းများ အဆင်ပြေမည် ။

အခြားဥပမာကို ကြည့်ကြပါစို့။

ဥပမာ

<?php
class Fruit {
  public $name;
  public $color;
  public function __construct($name, $color) {
    $this->name = $name;
    $this->color = $color;
  }
  protected function intro() {
    echo "The fruit is {$this->name} and the color is {$this->color}.";
  }
}

class Strawberry extends Fruit {
  public function message() {
    echo "Am I a fruit or a berry? ";
    // Call protected method from within derived class - OK
    $this -> intro();
  }
}

$strawberry = new Strawberry("Strawberry", "red"); // OK. __construct() is public
$strawberry->message(); // OK. message() is public and it calls intro() (which is protected) from within the derived class
?>

အထက်နမူနာတွင် အားလုံးအဆင်ပြေကြောင်း ကျွန်ုပ်တို့မြင်ရသည်။ protected အဘယ်ကြောင့်ဆိုသော် ကျွန်ုပ်တို့သည် ဆင်းသက်လာသော class အတွင်းမှ method (intro()) ကို ခေါ်သောကြောင့် ဖြစ်သည်။


PHP - အမွေဆက်ခံသည့်နည်းလမ်းများကို ဦးစားပေးခြင်း။

ကလေးအတန်းအစားရှိ နည်းလမ်းများ (အမည်တူ) ကို ပြန်လည်သတ်မှတ်ခြင်းဖြင့် အမွေဆက်ခံသည့်နည်းလမ်းများကို လွှမ်းမိုးနိုင်သည်။

အောက်ပါဥပမာကိုကြည့်ပါ။ ကလေးအတန်းအစား (Strawberry) ရှိ __construct() နှင့် intro() နည်းလမ်းများသည် ပင်မအတန်းရှိ __construct() နှင့် intro() နည်းလမ်းများကို အစားထိုးပါမည်-

ဥပမာ

<?php
class Fruit {
  public $name;
  public $color;
  public function __construct($name, $color) {
    $this->name = $name;
    $this->color = $color;
  }
  public function intro() {
    echo "The fruit is {$this->name} and the color is {$this->color}.";
  }
}

class Strawberry extends Fruit {
  public $weight;
  public function __construct($name, $color, $weight) {
    $this->name = $name;
    $this->color = $color;
    $this->weight = $weight;
  }
  public function intro() {
    echo "The fruit is {$this->name}, the color is {$this->color}, and the weight is {$this->weight} gram.";
  }
}

$strawberry = new Strawberry("Strawberry", "red", 50);
$strawberry->intro();
?>

PHP - နောက်ဆုံးသော့ချက်စာလုံး

သော့ချက်စကားလုံးကို အတန်း အ final မွေဆက်ခံခြင်းကို တားဆီးရန် သို့မဟုတ် နည်းလမ်းကို ထပ်လောင်းခြင်းမှ ကာကွယ်ရန် အသုံးပြုနိုင်သည်။

အောက်ဖော်ပြပါ ဥပမာသည် အတန်းအမွေဆက်ခံခြင်းကို မည်သို့တားဆီးရမည်ကို ပြသသည်-

ဥပမာ

<?php
final class Fruit {
  // some code
}

// will result in error
class Strawberry extends Fruit {
  // some code
}
?>

အောက်ဖော်ပြပါ ဥပမာသည် နည်းလမ်းအား လွှမ်းမိုးခြင်းမှ ကာကွယ်ရန် နည်းလမ်းကို ပြသသည်-

ဥပမာ

<?php
class Fruit {
  final public function intro() {
    // some code
  }
}

class Strawberry extends Fruit {
  // will result in error
  public function intro() {
    // some code
  }
}
?>