• Aggregation ga misol
  • MVC texnologiyasi
  • 20-maruza: phpda obyektga yonaltirilgan dasturlash. Mvc texnologiyasi




    Download 20,38 Kb.
    bet6/6
    Sana30.01.2024
    Hajmi20,38 Kb.
    #148601
    1   2   3   4   5   6
    Bog'liq
    20-maruza phpda obyektga yo’naltirilgan dasturlash. Mvc texnolo-www.kompy.info

    Composition ga misol


    class Author {
    private $name;
    private $email;
    public function __construct($name,$email){
    $this->name = $name;
    $this->email = $email;
    }
    public function getName(){
    return $this->name;
    }
    public function getEmail(){
    return $this->email;
    }
    }
    class Book {
    //using array to allow multiple authors
    private $authors = array();
    private $price;
    private $name;
    public function __construct($name,$price){
    $this->name = $name;
    $this->price = $price;
    }
    public function setPrice($price){
    $this->price = $price;
    }
    public function getPrice(){
    return $this->price;
    }
    public function getName(){
    return $this->name;
    }
    public function addAuthor($name,$email){
    $this->authors[] = new Author($name,$email);
    }
    public function getAuthors(){
    return $this->authors;
    }}
    $book = new Book('Book Name',10.0);
    $book -> addAuthor('Kelly','kelly@brainbell.com');
    $book -> addAuthor('Ken','ken@brainbell.com'); /* print book info */
    echo $book -> getName();
    echo $book -> getPrice(); /* print book's authors info */
    $authors = $book -> getAuthors(); //Array of authors
    foreach ($authors as $author) {
    echo $author -> getName();
    echo $author -> getEmail();
    }

    Aggregation ga misol


    class Author {
    private $name;
    private $email;
    public function __construct($name,$email) {
    $this->name = $name;
    $this->email = $email;
    }
    public function getName() {
    return $this->name;
    }
    public function getEmail(){
    return $this->email;
    }
    }
    class Book {
    private $authors;
    private $price;
    private $name;
    public function __construct($name,$price,$author){
    $this->name = $name;
    $this->price = $price;
    $this->author = $author;
    }
    public function setPrice($price){
    $this->price = $price;
    }
    public function getPrice(){
    return $this->price;
    }
    public function getName(){
    return $this->name;
    }
    public function getAuthor(){
    return $this->author;
    }
    }
    $author = new Author(Sarvar',webga kirish',10.0,$author);
    echo $book->getName(); //webga kirish
    echo $book->getAuthor() -> getName(); //Sarvar
    echo $book->getAuthor() -> getEmail(); //sarvar@gmail.com

    MVC texnologiyasi

    Server tomon uchun mominlashga erishish lozim. Buning uchun hozirgi kunda ommalashgan webga mollaniladi

    WEB ilova uchun MVC loyihalash strukturasi

    MVC texnologiyasi

    MVC (Model View Controller) konsepsiyasini qollab quvvatlanishidir. Foydalanuvchiga zarur marovlarning qanday qurilmadan (shaxsiy kompyuter yoki mobil telefondan) ekanligini farqlashi lozim. Bunda malumotni turli platformalarga mos holda shakllantirib beradi.


    http://kompy.info
    Download 20,38 Kb.
    1   2   3   4   5   6




    Download 20,38 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    20-maruza: phpda obyektga yonaltirilgan dasturlash. Mvc texnologiyasi

    Download 20,38 Kb.