WordPress Actions and Filters add_action - init - within class object


Example

 class sample{

     public function __construct(){
         add_action('init', array($this, 'samp') );
     }


     public function samp(){ // must be public!!
         echo 'i did something';
     }
 }

 new sample();