yii 关于createUrl跟CHtml:link参数设置的区别
yii 关于createUrl和CHtml::link参数设置的区别
1,createUrl应用
2,CHtml::link应用
希望对你们有帮助!
1,createUrl应用
<a href="<?php echo $this->createUrl('news/view',array('id'=>$companyNew->id,'news_type'=>$companyNew->news_type)) ?>" title="<?php echo $companyNew->title ?>">
2,CHtml::link应用
<?php echo CHtml::link(CHtml::encode($data->title), array('view', 'id'=>$data->id,'news_type'=>$data->news_type)); ?> //例如: <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1'));?> html输出是<a href="index.php?r=controller/action¶m1=value1">Link Text</a> //多参数 <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1','param2'=>'value2'));?> html输出是<a href="index.php?r=controller/action¶m1=value1¶m2=value2">Link Text</a> //额外参数: <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1'), array('target'=>'_blank'));?> html输出是<a target="_blank" href="index.php?r=controller/action¶m1=value1">Link Text</a> //绝对路径: <?php echo CHtml::link('Link Text', array('/controller/action'));?> //指定模块下的路径 <?php echo CHtml::link('Link Text', array('/module-id/controller/action'));?> //无效链接: <?php echo CHtml::link('Link Text', array('href'=>'javascript:void(0)'));?> <a href="javascript:void(0)">Link Text</a>
希望对你们有帮助!