Custom classes cannot be instantiated! Nausea related problems send points! (New zendframework with Zend Studio)

Source: Internet
Author: User
Custom classes cannot be instantiated!!! Disgusting problem send points!! (New zendframework with Zend Studio)


Models under denglu.php code:
Class denglu{
protected $_username;
protected $_password;
Public Function Denglu () {

}
Public Function Iddeng () {
if ($this->_username== ' Mr ') && ($this->_password== ' Pass ')) {
return true;
}else {
return false;
}
}
}

Controllers under selfcontroller.php Code:

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", "Web Login Interface");
$this->view->assign ("Test", "Web Interface");
if ($this->_request->ispost ()) {
$username = $this->_request->getpost (' username ');
$password = $this->_request->getpost (' password ');
$dengl =new Denglu (); Cannot instantiate!!!!!!!!
}
}
}

Annoying me a few days!!!! It's annoying,!!!!!!!!!!!!.

------Solution--------------------
Let me fix it for you! There are two ways of doing this:
The first type: Modify your portal file index.php as follows:
Set_include_path (Implode (path_separator, Array (
Realpath (Application_path. '/.. /library '),
Realpath (Application_path. '/.. /library/models '),
Get_include_path (),
)));
/*-------------contains Zend Auto-load class */
Require_once "zend/loader/autoloader.php";
Zend_loader_autoloader::getinstance ()->setfallbackautoloader (true);

The second: under your/application/there is a bootstrap.php file that adds the following code to the file:
/**
* Auto Load Class
*/
protected function _initautoload ()
{
$moduleLoader = new Zend_application_module_autoloader (
Array
' Namespace ' = ',
' BasePath ' = Application_path
)
);
return $moduleLoader;
}

Then the models folder inside the class named Model_denglu, the file name is preferably denglu.php (first letter capital)
Instantiate when this is used $dengl=new Model_denglu ();
Both of these 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.