Php class_php instance

Source: Internet
Author: User
Php /*----------------------------------------------------------------//
* Class: Ini
* Function: to install the system which is requested from client
* Author: Kevin #
* QQ: 84529890
* Date: 2006.10.24
//----------------------------------------------------------------*/
Require_once (CLASS_SYS_PATH. "class. db. php ");
Class Ini {
/*
* Member variable $ defaplay play
* To set the variable play
*/
Var $ defaplay play = "main ";
/*
* Member variable $ DB
* To set the object: database
*/
Var $ DB;
/*
* Member variable $ play
* Record the parameter of play
*/
Var $ play;
/// // @ Member function list @@@@\\\\\\\
//-============================================== = -\\
// LastModifyTime: 2006.11.16
//-============================================== = -\\
//////////////////////////////////////// ////
/*
* Function: setDB ($ db)
* Set the global database object
*/
Function setDB ($ db ){
Return $ this-> DB = $ db;
}
/*
* Function: loadSystem ($ play)
* Load system
*/
Function loadSystem ($ play ){
If ($ this-> isValidPlay ($ play )){
Require_once ("class. smarttemplate. php ");
Require_once ($ play );
$ PlayLikeABird = new Main;
} Else {
$ This-> halt ("Invalid Access ....");
}
}
/*
* Function: iniCon ()
* Install database
*/
Function iniCon (){
Global $ DB;
$ DB = new DB (HOST_ADDR, HOST_USER, HOST_PSW, DB_NAME );
}
/*
* Function: getDB ()
* To get the current database object
*/
Function getDB (){
Return $ this-> DB;
}
/*
* Function: getPlay ()
* Get the play which is post from client
*/
Function getPlay (){
Return $ play = empty ($ _ REQUEST ["play"])? $ This-> defaultPlay: $ _ REQUEST ["play"];
}
/*
* Function: isValidPlay ($ play)
* To check legitimacy if the play parameter is
*/
Function isValidPlay ($ play ){
If (file_exists ($ play )){
Return true;
} Else {
Return false;
}
}
/*
* Function: halt ($ msg)
* Show message on the browser
*/
Function halt ($ msg ){
Echo "". $ msg. "\ n
";
}
/*
* Function: iniSystem ()
* Install system
*/
Function iniSystem (){
$ This-> iniCon ();
$ This-> setDB ($ DB );
$ Play = $ this-> getPlay ();
Return $ play = $ this-> resetPlay ($ play );
}
/*
* Function: resetPlay ($ p)
* To re-define the play's parameter
*/
Function resetPlay ($ p ){
Return $ p = CLASS_PATH. ENTRY_FIRST_FORMAT. $ p. ENTRY_LAST_FORMAT;
}
/*
* Function: Ini ()
* To link the database and get the play which post from client
*/
Function Ini (){
$ Play = $ this-> iniSystem ();
$ This-> Debug ($ play );
$ This-> loadSystem ($ play );
$ This-> close ();
}
/*
* Function: debug ($ play)
* To show the debug information
*/
Function debug ($ play ){
If (DEBUG) $ this-> halt ("Play-> $ play ");
}
/*
* Function: close ()
* Unset database
*/
Function close (){
Return $ this-> DB = NULL;
}
/// // Define class over @@@@@ @@@@@@@@@@@@@@@@@@@@\\\\\\\\
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.