如何使用&如何在codeigniter中编写url helper的格式

时间:2016-06-29 06:53:17

标签: php codeigniter

我有这样的代码

<a href="<?php base_url() ?>product/detail/<?php echo $i->product_name_seo ?>">
    <img src="<?php echo base_url()."upload_image/product/".$i->image ?>" alt="product image" width="72" height="72">
</a>

如何在URL帮助程序锚中重写此代码..?

3 个答案:

答案 0 :(得分:1)

试试这个

    $this->load->helper(array('url','html'));
    $image_properties = array(
        'src' => 'upload_image/product/' . $i->image,
        'alt' => 'product image',
        'width' => '72',
        'height' => '72'
    );

    $img = img($image_properties);
    echo anchor('product/detail'.$i->product_name_seo, $img);

答案 1 :(得分:0)

 $image = '<img src="<?php echo base_url('upload_image/product/'.$i->image)?>" alt="product image" width="72" height="72">'

<?php echo anchor('product/detail/'.$i->product_name_seo, $image);?>

答案 2 :(得分:0)

<a href="<?php base_url(); ?>product/detail/<?php echo $i->product_name_seo; ?>">

<img src="<?php echo base_url(); ?>upload_image/product/<?php echo $i->image; ?>" alt="product image" width="72" height="72"></a>