PHP

[email protected]

   

การเรียกใช้ฟังก์ชั่น ในคลาส


วิธีการใช้
  • var $width; //กำหนดตัวแปรที่ใช้ในคลาส
  • $this->width = "100%"; //การเรียกใช้ตัวแปร
  • $prg->width = "50%";//การเรียกใช้ตัวแปร ภายนอกคลาส
  •  
    Ex.
    php.class.php
    <?php
    class phpClass { var $width;
    function example1(){ $this->width="100%"; echo "Example1: ".$this->width; }// end function example1() function example2(){ echo "Example2: ".$this->width; }// end function example2()
    }// end class ?>

    การเรียกใช้ <?php include_once("php.class.php"); $prg = new phpClass(); //กำหนดตัวแปรที่รับกับคลาสที่จะใช้ $prg->example1(); $prg->width = "50%"; $prg->example2(); ?>

    Output : Example1: 100% Example2: 50%

      ที่มา:=> สร้างเอง PHP ที่ทดสอบ v4.3.4


    สร้างเมื่อวันที่ : 22-07-2548

    เกี่ยวกับเรา | Site Map | Privacy Policy | ติดต่อเรา | ©2005 Company Name

    Hosted by www.Geocities.ws

    1