CodeIgniter - 简单的 base_url 问题 [英] CodeIgniter - Simple base_url question

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

问题描述

我在这里有点困惑.

我有一个加载视图的简单控制器.该视图包含一个表单并链接一些 CSS 文件.我真的不想在我的链接标签中做 ../../css/global.css .我想使用 base_url() 方法,然后转到/css/.

I have a simple controller which loads a view. The view contains a form and links some CSS files. I don't really want to do ../../css/global.cssin my link tag. I want to use the base_url() method and then go /css/.

我知道一个朋友使用以下内容:

I know a friend uses the following:

  <link href="{base_url}css/style.css" rel="stylesheet" type="text/css" />

但是,我无法让它发挥作用.不过他使用的是 CodeIgniter 1.7,我使用的是最新的 (2.something) 版本.我是 CodeIgniter 的新手,我想弄乱它,但我什至无法链接一个简单的 CSS 文件:(

However, I can't get that to work. He uses CodeIgniter 1.7 though, I'm using the latest (2.something) version. I'm new to CodeIgniter and I wanted to mess around with it, but I can't even link a simple CSS file :(

我的视图在/logic/views/index.php,我的css文件在/css/

My view is in /logic/views/index.php, my css files are in /css/

非常感谢.

推荐答案

我认为你的问题是 base_url 是 ci 2+ 中的一个函数,所以试试这个

I think your problem is that base_url is a function in ci 2+ so try this instead

<link href="<?php echo base_url() ?>css/style.css" 
rel="stylesheet" type="text/css" />

这取决于你如何定义 base_url 如果你做了一个结束斜杠,否则只需添加一个斜杠

It depends how you defined base_url if you did an ending slash otherwise just add a slash so

/css/style.css

这篇关于CodeIgniter - 简单的 base_url 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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