How to get base url in CodeIgniter 2.*

前端 未结 5 1179

In config.php

$config[\'base_url\'] = \'http://localhost/codeigniter/\';

In View



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 18:10

    To use base_url() (shorthand), you have to load the URL Helper first

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

    Or you can autoload it by changing application/config/autoload.php

    Or just use

    $this->config->base_url();
    

    Same applies to site_url().

    Also I can see you are missing echo (though its not your current problem), use the code below to solve the problem

    
    

提交回复
热议问题