如何获取基本url在CodeIgniter 2. * [英] How to get base url in CodeIgniter 2.*
本文介绍了如何获取基本url在CodeIgniter 2. *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在config.php
In config.php
$config['base_url'] = 'http://localhost/codeigniter/';
在查看
<link rel="stylesheet" href="<?php base_url(); ?>css/default.css" type="text/css" />
=>错误:调用未定义函数base_url();
帮助我
推荐答案
c> base_url()(速记),您必须首先加载 URL Helper
To use base_url()
(shorthand), you have to load the URL Helper
first
$this->load->helper('url');
或,您可以通过更改 /config/autoload.php
或只需使用
$this->config->base_url();
同样适用于 site_url()
。
此外,我可以看到你缺少 echo
(虽然它不是你当前的问题),请使用下面的代码来解决问题
Also I can see you are missing echo
(though its not your current problem), use the code below to solve the problem
<link rel="stylesheet" href="<?php echo base_url(); ?>css/default.css" type="text/css" />
这篇关于如何获取基本url在CodeIgniter 2. *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文