Im using Zend Framework v1.11.0.I have the following code in my IndexController.php.
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'Web site home';
}
}
?>
But, if i navigate to:开发者_开发问答http://projectname i get a blank page and if i go to:http://projectname/index i get Error 404.
However,if i replace the indexAction word by the word init and then navigate to:http://projectname i get 'Web site home' echoed.
How can this be fixed ?
Thank You.
You're probably getting a 404 because you don't have view for the action created, you normally don't echo
content form a controller, you just set up variables for the view. IF you're just doing a quick test then you can use an exit
statement right after your echo
.
Normally it would look like this:
in Index application/controllers/indexController.php
public function indexAction()
{
$this->view->message = 'Web site home';
}
in application/views/scripts/index/index.phtml
<?php if(isset($this->message)): ?>
<?php echo $this->message; ?>
<?php endif; ?>
精彩评论