dpvomqeu396484 2014-04-24 05:22
浏览 62
已采纳

我不能使用yii框架在视图文件中包含图像

I am new in yii framework. I am trying to include image in view file in yii framework. View file is in admin module,but image is in my root folder. My root folder is 'jobseeker'. Image is in 'images' folder inside jobseeker folder. Name of image is 'update.png'.

My View file's name is list_jobseeker.php

I am including image this way:

 <?php echo CHtml::image(Yii::app()->request->baseUrl.'/images/update.png',    array('site/job_apply'));?>

I got the error: htmlspecialchars() expects parameter 1 to be string, array given

  • 写回答

1条回答 默认 最新

  • dongmiao260399 2014-04-24 05:35
    关注

    Second parameter in CHtml::image is alt attribute of img element. So your image including code should be something like:

    <?php echo CHtml::image(Yii::app()->request->baseUrl.'/images/update.png'
    , 'update'); ?>
    

    If you want image to be a link then use CHtml::link with CHtml::image:

    <?php $img = CHtml::image(Yii::app()->request->baseUrl.'/images/update.png'
        , 'update');
           echo CHtml::link($img, Yii::app()->createUrl('site/job_apply'));
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?