CodeIgniter - 简单base_url问题 [英] CodeIgniter - Simple base_url question
问题描述
我有点困惑这里。
我有一个简单的控制器加载视图。视图包含一个表单并链接一些CSS文件。我真的不想在我的链接标记中做 ../../ css / global.css
。我想使用base_url()方法,然后go / 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.css
in 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+中的函数, this
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屋!