codeigniter base_url inside constants file
codeigniter, codeigniter-2, php
Solution
constants.php loading before config.php, so you can't use `$config['base_url']` from constants.php.
But you can do something like that:
constants.php:
define('BASE_URL', "http://mysite.com");
define('USER_UPLOAD_URL', BASE_URL."uploads/user_uploads/");
config.php
$config['base_url'] = BASE_URL;
Problem
Currently I display images in the following way: ``` <img src="<?php echo base_url().USER_UPLOAD_URL.$post['userPhoto'] ?>" /> ``` USER_UPLOAD_URL is defined inside application/config/constants.php. ``` define('USER_UPLOAD_URL', "uploads/user_uploads/"); ``` Is there any way to include base_url() inside constants.php? In this way I wouldn't need to write each time base_url() inside view. Is there any alternative approach? tnx