* * Édition2: Core.php n'a pas été trouvé car Bootstrap.php requis Core.php inclus require_once 'C: \ wamp \ www \ PhpProject1 \ application \ Core \ Core. php '; résolu mon problème **Zend Framework: Fonction d'appel d'un autre fichier
J'utilise zendframework et je créé un nouveau dossier avec le fichier de base/core.php pour mes fonctions que je vais utiliser dans mes contrôleurs et ailleurs. Mais quand j'essaye de tester une fonction dans mon Core.php rien n'apparaîtra. Je pense que j'appelle le core.php incorrectement mais je ne suis pas sûr de ce que l'erreur est.
application/controllers/
IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
$this->tournamentAction();
}
public function indexAction(){
}
public function tournamentAction()
{
$bleh = new Core();
$this->view->ha = $bleh->yo();
$this->renderScript('tournament/index.phtml');
}
}
demande
/Core/
core.php
class Core{
public function init(){
}
public function indexAction(){
}
public function yo(){
$text = 'This is my function Yo';
return $text;
}
demande
/views/scripts/tournois/index .phtml
$this->ha;
echo "hello";
Édition: Le rapport d'erreur est agréable ha! C'est l'erreur que je reçois.
!) Fatal error: Class 'Core' not found in C:\wamp\www\PhpProject1\application\controllers\IndexController.php on line 19
Call Stack
# Time Memory Function Location
1 0.0006 678944 {main}() ..\index.php:0
2 0.0275 3090632 Zend_Application->run() ..\index.php:26
3 0.0275 3090632 Zend_Application_Bootstrap_Bootstrap->run() ..\Application.php:366
4 0.0275 3090728 Zend_Controller_Front->dispatch() ..\Bootstrap.php:97
5 0.0446 4801056 Zend_Controller_Dispatcher_Standard->dispatch() ..\Front.php:954
6 0.0456 4823424 Zend_Controller_Action->__construct() ..\Standard.php:268
7 0.0547 5211576 IndexController->init() ..\Action.php:133
8 0.0547 5211576 IndexController->tournamentAction() ..\IndexController.php:8
Vous n'avez jamais 'echo' ou' print' le '$ this-> ha'. – PeeHaa
Je viens de faire ce changement mais il n'a toujours rien imprimé. – tiggles
Est-ce qu'il est imprimé quand vous faites: echo $ this-> ha; mourir; – PeeHaa