Yii - 使用CHTML :: link()创建绝对URL

时间:2014-03-17 10:56:41

标签: php html yii yii-chtml

我已经使用CHTML :: link()来创建链接,但它似乎不适用于绝对URL

我的代码:

<?php echo CHtml::link(CHtml::image(Yii::app()->baseUrl.'/images/image.png'), array('/http://www.newsite.com/about/'));?>

该链接返回网站baseUrl,因此它显示为

http://currentsitecom/http://www.newsite.com/about/

有谁能说明为什么这不起作用?

1 个答案:

答案 0 :(得分:0)

该链接在/

之前不应该http://
<?php echo CHtml::link(
    CHtml::image(Yii::app()->baseUrl.'/images/image.png'),
    array('http://www.newsite.com/about/')
);?>
相关问题