Saturday, June 1, 2013

Using Construct To Automatically Initiate Specific Functions Using Only The New Class Call !

class Example
 public function __construct()
 }//end function construct//

 public function doSomething()
  echo 'Construct Auto Initiates our doSomething function.';
 }//end function doSomething//

}//end class

 $example = new Example;        //we call our class//
 //$example->doSomething();    //now using contruct We Do Not Need This Line.//

The construct function executes our doSomething function Automatically. 

The example above will be very useful when creating a database connection class or as a refined way to pass class functions to other classes similar to Framework Development.

No comments:

Post a Comment