用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1785|回复: 2
收起左侧

一个可疑的注册函数的可疑的疑惑

[复制链接]
发表于 2012-9-13 14:57:51 | 显示全部楼层 |阅读模式
本帖最后由 haoshaoyee 于 2012-9-13 15:08 编辑

用了smarty模板 在扩展的smarty类里一部分是这样写的

require_once( APPPATH.'third_party/smarty/libs/Smarty.class.php' );

class CI_Smarty extends Smarty
{
        var $CI;
        function __construct()
        {
                parent::__construct();
               
                $this->CI =& get_instance();
                $this->CI->load->helper('url');
                $this->registerPlugin('function','site_url ','site_url');
                $this->registerPlugin('function','base_url ','base_url');

           ............................

配置文件里是这样的
$config['base_url']        = 'http://xx.com';
$config['index_page'] = 'index.php';

然后模板调用
{site_url a=x b=y c=z}  //效果为 http://xx.com/index.php/x/y/z.html
{base_url  a=x b=y c=z}  //效果为  http://xx.com/x/y/z

求解 这里是怎么出来的 看了下Config类的这两函数 貌似没有extract之类的呀,做了个exit
感觉这到挺方便的 但是不敢用 不明其理

真是笨啊 手册上明明写了
这是一个以数组形式传递 URI 段的例子:
$segments = array('news', 'local', '123');

echo site_url($segments);可以用数组的嘛

发表于 2012-9-13 15:15:55 | 显示全部楼层
分不清
发表于 2012-9-13 16:11:34 | 显示全部楼层
site_url 和 base_url 是两个 helper,仔细看手册 http://codeigniter.org.cn/user_guide/helpers/url_helper.html

本版积分规则