亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何獲取完整的 URL 以在 laravel 中顯示

如何獲取完整的 URL 以在 laravel 中顯示

PHP
神不在的星期二 2022-07-09 18:29:22
我是 laravel 的初學者,我想在頁面上顯示當前頁面的實時 URL。// 完整的 URL,帶有查詢字符串 $request->fullUrl()// 只是 URL 的路徑部分 $request->path()// 只是 URL 的根(協議和域)部分) $request->r強調文本oot()在谷歌上搜索后我發現了這個,誰能告訴我這是否是正確的方法,如果它是如何實現的。比如在“ Routes ”中寫什么,在“ controller ”中寫什么。
查看完整描述

2 回答

?
千萬里不及你

TA貢獻1784條經驗 獲得超9個贊

從文檔:


// Get the current URL without the query string...

echo url()->current();


// Get the current URL including the query string...

echo url()->full();

這些方法中的每一個也可以通過 URL 外觀訪問:


use Illuminate\Support\Facades\URL;


echo URL::current();

如果您使用命名路由(非強制性):


echo route('post.show', ['post' => 1]);


// http://example.com/post/1


查看完整回答
反對 回復 2022-07-09
?
呼喚遠方

TA貢獻1856條經驗 獲得超11個贊

獲取完整、當前和以前的 URL


// Get the current URL without the query string...

echo url()->current();



// Get the current URL including the query string...

echo url()->full();



// Get the full URL for the previous request...

echo url()->previous();

獲取特定的 URL 段


{{ Request::segment(1) }}


查看完整回答
反對 回復 2022-07-09
  • 2 回答
  • 0 關注
  • 236 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號