Codeigniter文件路径 [英] Codeigniter File Paths

查看:128
本文介绍了Codeigniter文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,但是我对codeigniter中的文件路径有些困惑,因为您可能会或可能不会知道CI会按以下方式布置其文件系统:

sorry to bother but I am having some confusion with filepaths within codeigniter, as you may or may not know CI lays out its file system as follows:

-application:
             -controllers
             -views
             -models
-system(contains CI framework)

我已经创建了一个css文件,并将一些图像保存在资源文件夹中,如下所示:

I have created a css file and have some images saved in the a resources folder like so:

 -application:
             -controllers
             -views
             -models
-system(contains CI framework)

-resources
     -img001
     -style.css

我在想,是否有人可以指出正确的方向来使用相对路径访问资源文件夹.

I was wondering whether someone could point me in the right direction to accessing the resources folder using relative paths.

推荐答案

您可以使用base_url函数.要使用此功能,您必须加载url helper

You can use base_url function. To use this function you have to load url helper

您可以按如下所示在任何需要的地方加载:

You can load wherever it required as below:

$this->load->helper('url');

或者您可以在autoload.php中进行设置.

Or you can set in autoload.php.

echo base_url("resources/img001/img_name.jpg");
echo base_url("resources/style.css");

这篇关于Codeigniter文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆