122-PHP class member function (c)

<? PHP
     class REN {         // define human 
        private  function Dance () {         // definition of private member method Dance 
            echo 'I want to dance. ' ;
        }
        private  function Sing () {         // definition of private member method Sing 
            echo 'I want to sing a song. ' ;
        }
        public  function do_something ( $ Item ) {         // definition of public member method do_something 
            Switch ( $ Item ) {
                 Case 'Dance':
                     $ the this -> Dance ();         // call the class member method Dance 
                    BREAK ;
                 Case 'Sing':
                     $ the this -> Sing ();         // call the class member method Sing 
                    BREAK ;
            }
        }
    }
    REN $ = new new REN ();         // instantiate a human subject
    // class member access method and passing a different parameter 
    $ REN -> do_something ( 'Sing' );
     $ REN -> do_something ( 'Dance' );
 >?

 

Guess you like

Origin www.cnblogs.com/tianpan2019/p/11008943.html