Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 听起来很简单,但不起作用:在CodeIgniter 2.1.3中导入CSS_Php_Codeigniter_Codeigniter 2_Codeigniter Routing - Fatal编程技术网

Php 听起来很简单,但不起作用:在CodeIgniter 2.1.3中导入CSS

Php 听起来很简单,但不起作用:在CodeIgniter 2.1.3中导入CSS,php,codeigniter,codeigniter-2,codeigniter-routing,Php,Codeigniter,Codeigniter 2,Codeigniter Routing,我刚刚下载了CodeIgniter 2.1.3,并试图通过header_controller将css导入 我已经试过了,和。我完全糊涂了,找不到简单的答案。是否有人对如何在CodeIgniter 2.1.3版上导入CSS和JS有一个简单的答案 我有:register.php <?php class register extends CI_Controller { public function index() { //Get header

我刚刚下载了CodeIgniter 2.1.3,并试图通过header_controller将css导入

我已经试过了,和。我完全糊涂了,找不到简单的答案。是否有人对如何在CodeIgniter 2.1.3版上导入CSS和JS有一个简单的答案

我有:
register.php

<?php

class register extends  CI_Controller {

    public function index()
    {

        //Get header
        $this->load->view('header');

        //Any other class
        $this->load->view('register');

    }
}
这是我的项目文件夹:(如果你想指导我在哪里可以放置CSS)


谢谢。

在您的查看页面上添加以下内容:

 <link rel="stylesheet" href="<?php echo base_url();?>css/bootstrap.css" type="text/css" media="screen"/>

在您的查看页面上添加以下内容:

 <link rel="stylesheet" href="<?php echo base_url();?>css/bootstrap.css" type="text/css" media="screen"/>
这应该行得通

<link rel="stylesheet" href="<?php echo base_url('css/bootstrap.css')?>" type="text/css" media="screen"/>
这应该行得通

<link rel="stylesheet" href="<?php echo base_url('css/bootstrap.css')?>" type="text/css" media="screen"/>

仅限于猜测,但为了能够使用base_url(),您需要在控制器中加载url帮助程序。此外,正如@hakre在评论中所说的,请打开错误报告

class register extends  CI_Controller {

    public function index()
    {
        $this->load->helper('url');

        //Get header
        $this->load->view('header');

        //Any other class
        $this->load->view('register');

    }
}

只是猜测,但为了能够使用base_url(),您需要在控制器中加载url帮助程序。此外,正如@hakre在评论中所说的,请打开错误报告

class register extends  CI_Controller {

    public function index()
    {
        $this->load->helper('url');

        //Get header
        $this->load->view('header');

        //Any other class
        $this->load->view('register');

    }
}

什么不适合你?您输出的URL是否错误?@hakre因此,当我在标题中添加标记时,页面变为空白,没有输出任何内容。“页面变为空白,没有输出任何内容”-这是一个非常常见的错误,请参阅,IIRC,这是第一个条目。在控制器中加载URL帮助程序$这->加载->帮助程序('url')并跟随@Hakrewahat的注释,这对您不起作用?您输出的URL是否错误?@hakre因此,当我在标题中添加标记时,页面变为空白,没有输出任何内容。“页面变为空白,没有输出任何内容”-这是一个非常常见的错误,请参阅,IIRC,这是第一个条目。在控制器中加载URL帮助程序$这->加载->帮助程序('url')并跟随@hakreSimple的注释,这是一条永远的主线!你可以竖起大拇指看我的书。如果您愿意的话。为了增加这一点,1)自动加载URL帮助程序非常有用,2)
base\u URL
接受一个字符串参数,表示应该位于基本URL之后的任何内容。它使输出更容易。例如,
echo base_url('css/bootstrap.css')简单,永远是一条主线!你可以竖起大拇指看我的书。如果您愿意的话。为了增加这一点,1)自动加载URL帮助程序非常有用,2)
base\u URL
接受一个字符串参数,表示应该位于基本URL之后的任何内容。它使输出更容易。例如,
echo base_url('css/bootstrap.css')