Live Brilliant

PHP OOP 프로그래밍 본문

개발은 핵찜이야/PHP

PHP OOP 프로그래밍

주인정 2012. 7. 2. 16:26

OOP : object oriented programming 객체 지향 프로그래밍.

 

 

class Test

{

    

    function __construct()

    {

        echo '생성자 :item created<br/>';

    }

    

    function __destruct()

    {

        echo '소멸자 :item erased<br/>';

    }

    

    function Hello()

    {

        echo 'hello';

    }

    

    function __get($param)

    {

        echo "$param does not exist<br/>";

    }

    

    function __set($name, $value)

    {

        echo "set property $name->$value <br/>";

        $this->{$name} = $value;

    }

    

    function __call($param, $value)

    {

        echo "call process $param($value) <br/>";

        print_r($value);

    }

}


$t = new Test(); //생성자


$t->hello; //get 호출
결과 : hello does not exist


$t->age = 12; //set 호출

결과 : set property age->12 


$t->SomethingThatDoesntExist('123','123','123') //call 호출

결과 : call process SomethingThatDoesntExist(Array) 

Array ( [0] => 123 [1] => 123 [2] => 123 ) 


생성자 :item created

소멸자 :item erased

 

Comments