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', true);
 
// https://www.example.com/index.php?r=site/index
echo Url::toRoute('site/index', 'https');


echo Yii::$app->urlManager->createUrl('site/index')


转::http://lmh860628.blog.163.com/blog/static/193976102201551210025248/

阅读更多
换一批

没有更多推荐了,返回首页