-1

我在 CodeIgniter 中创建了两个视图,并创建了名为HelloWorld.php
它的控制器,它包含两个视图。但我的问题是第二个视图永远不会被调用。

http://localhost/CodeIgniter/HelloWorld/Hello

对我来说很好,但第二个视图

http://localhost/CodeIgniter/HelloWorld/Buzz

不调用第二个视图

这是我的代码

<?php

class HelloWorld extends CI_Controller
{
    var $name;
    var $color;

    function __construct()
    {
        parent:: __construct();

        $this->name= 'Suzzu';
        $this->color = 'aqua';
    }

    public function Hello()
    {
        $this->load->view("hello");
    }

    public function Buzz()
    {
        $data['name'] = $this->name;
        $data['color'] = $this->color;

        $this->load->view("welcome",$data);
    }
}

有什么问题 ??

4

2 回答 2

0

Your code works as expected for me provided that:

  • there is a view file "views/welcome.php"
  • there is a view file "views/hello.php"

Can you verify that HelloWorld::Buzz() is being called?

public function Buzz()
{
    die('yes, it works');
}

If this function doesn't execute when you go to /localhost/CodeIgniter/HelloWorld/Buzz, can you provide the following:

  • $config['base_url'] (config/config.php)
  • $config['index_page']
  • config/routes.php contents
于 2013-08-22T16:46:15.467 回答
0

改变$config['base_url']="localhost/codeigniter/contollername"

于 2013-09-23T06:45:55.100 回答