Custom classes cannot be instantiated! Disgusting questions! (Use zendstudio to create zendframework)

Source: Internet
Author: User
Custom classes cannot be instantiated !!! Scores for nausea !! (Use zendstudio to create zendframework.) the code of denglu. php under models: & lt ;? Phpclassdenglu {protected $ _ username; protected $ _ password; the publicfunctiondeng custom class cannot be instantiated !!! Scores for nausea !! (Use zend studio to create zendframework)


Code of denglu. php under models:
Class denglu {
Protected $ _ username;
Protected $ _ password;
Public function denglu (){

}
Public function iddeng (){
If ($ this-> _ username = 'Mr ') & ($ this-> _ password = 'pass ')){
Return true;
} Else {
Return false;
}
}
}

SelfController. php code under controllers:

Class SelfController extends Zend_Controller_Action {
Public function init ()
{
/* Initialize action controller here */
}
Public function selfAction (){

}
// My page
Public function myAction (){
$ This-> view-> assign ("title", "webpage logon interface ");
$ This-> view-> assign ("test", "webpage interface ");
If ($ this-> _ request-> isPost ()){
$ Username = $ this-> _ request-> getPost ('Username ');
$ Password = $ this-> _ request-> getPost ('password ');
$ Dengl = new denglu (); // it cannot be instantiated !!!!!!!!
}
}
}

I have been bored for a few days !!!! Thank you !!!!!!!!!!!!

------ Solution --------------------
Let me solve it for you! There are two methods:
First, modify the index. php file of your portal as follows:
Set_include_path (implode (PATH_SEPARATOR, array (
Realpath (APPLICATION_PATH. '/../library '),
Realpath (APPLICATION_PATH. '/../library/models '),
Get_include_path (),
)));
/* ------------- Contains the zend automatic loading class */
Require_once "Zend/Loader/Autoloader. php ";
Zend_Loader_Autoloader: getInstance ()-> setFallbackAutoloader (true );

Type 2: There is a Bootstrap. php file under your/application/. add the following code to this file:
/**
* Automatically load classes
*/
Protected function _ initAutoLoad ()
{
$ ModuleLoader = new Zend_Application_Module_Autoloader (
Array (
'Namespace '=> '',
'Basepath' => APPLICATION_PATH
)
);
Return $ moduleLoader;
}

Name the class in the models folder as Model_Denglu. the file name should be Denglu. php (uppercase)
During the instantiation, $ dengl = new Model_Denglu () is used ();
The above two methods can be done.

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.