最新消息: 新版网站上线了!!!

yii2 url生成链接调用图片的方法

// /index?r=site/index
echo Url::to(['site/index']);
 
// /index?r=site/index&src=ref1#name
echo Url::to(['site/index''src' => 'ref1''#' => 'name']);
 
// the currently requested URL
echo Url::to();
 
// /images/logo.gif
echo Url::to('@web/images/logo.gif');
 
// images/logo.gif
echo Url::to('images/logo.gif');
 
// http://www.example.com/images/logo.gif
echo Url::to('@web/images/logo.gif', true);
 
// https://www.example.com/images/logo.gif
echo Url::to('@web/images/logo.gif''https');
 
 
 
// /index?r=site/index
echo Url::toRoute('site/index');
 
// /index?r=site/index&src=ref1#name
echo Url::toRoute(['site/index''src' => 'ref1''#' => 'name']);
 
// http://www.example.com/index.php?r=site/index
echo Url::toRoute('site/index' -->

转载请注明:谷谷点程序 » yii2 url生成链接调用图片的方法