Abstract class using php

? < PHP 

abstract  class Stu // define abstract class 
{
     const TITLE = 'my title' ;
     abstract  public  function name ( $ Age , $ Sex ); // define the abstract method 
}
 class the Sure the extends Stu // inherit the abstract class 
{
     public  function name ( $ Age , $ sex ) 
    { 
        $ STR = Self :: TITLE;
         $ STR . = '<br> age'. $ Age ', <br> gender'.. $ sex ;
        return  $ STR ; 
    } 
} 
// new new Stu; not new, otherwise an error. 
$ obj = new new of Sure ();
 echo  $ obj -> name (13 is, 'M');

Abstract methods must inherit otherwise error, simple to understand: 'The manager gave you a good definition, can not be complete without commuting.'.

Guess you like

Origin www.cnblogs.com/xm666/p/11266232.html