Codeigniter - 放置一个<?php base_url(); ?>作为控制器内部的源

I'm trying to put a link inside a source inside my controller.

Code:

$marker['icon'] = "<?php echo base_url('assets/dist/GMapMarkers/paleblue_MarkerH.png') ?>;"

but it doesn't load. I am guessing that echoing the base URL inside a controller won't work. Is there any other method to do this?

As base_url just returns string, you can assign this string to a variable and echo this variable later:

$marker['icon'] = base_url('assets/dist/GMapMarkers/paleblue_MarkerH.png');
echo $marker['icon'];

base_url is a function, you call it with param (string). Function combine base configs and your string, and returns completed url.

$marker['icon'] = base_url('assets/dist/GMapMarkers/paleblue_MarkerH.png');

The solution I found which is a modification on the other answers and shorter:

$marker['icon'] = $this->config->base_url('assets/dist/GMapMarkers/blue_MarkerL.png');