有多少例子我沒見過,都是本質上一樣的,都做同樣的事情。讓我們來看看其中的一個。
Route::current()->uri()
我們有 urlhttps://example.com/test并且我們得到test,并且在所有示例中都是相同的
但是如何確保我們得到的不僅僅是test斜線/test?
uj5u.com熱心網友回復:
你可以用這段代碼得到它:
request()->getPathInfo();
LaravelIlluminate/Http/Request擴展了Request包含getPathInfo方法的Symfony類。
檔案:https : //symfony.com/doc/current/components/http_foundation.html#identifying-a-request
您可以在此處找到該方法的定義。
uj5u.com熱心網友回復:
你可以試試這個:
request()->getPathInfo();
您可以在此處找到方法定義
uj5u.com熱心網友回復:
你可以在 laravel 中獲取 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();
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/331063.html
