echo anchor($url, $text);
Karena codeigniter tidak menyediakan function untuk link image, berarti anda harus membuat function tambahan. Aktifkan file system/helper/url_helper.php
lalu dibagian paling bawah sisipkan code berikut:
if ( ! function_exists('anchor_img')){
function anchor_img($uri = '',$img = '', $title = '', $attributes = ''){
$title = (string) $title;
if ( ! is_array($uri)){
$site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
}
else{
$site_url = site_url($uri);
}
if ($title == ''){
$title = $site_url;
}
if ($attributes != ''){
$attributes = _parse_attributes($attributes);
}
return '<a href="'.$site_url.'"><img src="'.base_url().'/'.$img.'" border=0></a>';
}
}
Untuk memanggilnya gunakan code ini:
echo anchor_img($url, $img);
$url : adalah link tujuan.
$img : adalah lokasi file image.
Nice article!
not working CI 2.0.3
Yes, this post for CI 1.7.2