This class is "freely declare"
class TrainingSearch2 {
// variable to hold singleton instance of this class
// to avoid multiple instantiated
private static $instance;
/**
* Main Instance
*
* @staticvar array $instance
* @return The one true instance
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
// register it self
self::$instance = new self;
// call the method to register menu and page
self::$instance->my_search();
}
// if instance already created just return it
return self::$instance;
}
Use $MySearch = MySearch::instance();
class TrainingSearch2 {
// variable to hold singleton instance of this class
// to avoid multiple instantiated
private static $instance;
/**
* Main Instance
*
* @staticvar array $instance
* @return The one true instance
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
// register it self
self::$instance = new self;
// call the method to register menu and page
self::$instance->my_search();
}
// if instance already created just return it
return self::$instance;
}
Use $MySearch = MySearch::instance();
Comments
Post a Comment