Pregunta

I'm trying to get another framework working inside of CodeIgniter and this other framework has it's own config file. One of the values it needs is the site or base url. I thought I'd simply use CI's base url value from the application/config/config.php file. I've tried two methods:

  1. Simply use base_url(). The url helper is being autoloaded. This produces "Fatal error: Call to undefined function base_url()"
  2. Do a require_once APPPATH . 'config/config.php';, then use $config['base_url']. This method works for using application/config/database.php's database values. But for the base url, I get this error: "Message: Undefined variable: config". I don't understand why it works for database.php but not config.php.

What is the correct way to do this?

¿Fue útil?

Solución

not sure if this will help but try it - go to your config file and make base url blank

$config['base_url'] = '';

go to the main index.php and look for

  * -------------------------------------------------------------------
  *  CUSTOM CONFIG VALUES

then insert this with your url

    $assign_to_config['base_url'] = 'http://yourdomain.com';

you should then be able to use base_url()

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top