在 laravel 5.1 中获取 fullUrl

2022-08-30 14:25:29

我有多个引导选项卡,其中每个选项卡都执行与其他选项卡不同的操作以进行演示

app-url/users#creat-admin-users-tab app-url/users#creat-regular-users-tab

在Laravel中是否有任何方法可以获得完整的url,包括#tab名称

感谢您抽出宝贵时间接受采访。


答案 1

Laravel具有返回当前URL的功能。所有这一切都在此页面中指定:http://laravel.com/api/5.0/Illuminate/Http/Request.html

你要找的是.Request::fullUrl()

假设我正在 http://laravel.dev/test?test=1,以下是方法和结果:

Request::fullUrl()
// Returns: http://laravel.dev/test?test=1
Request::url()
// Returns: http://laravel.dev/test
Request::path()
// Returns: test
Request::root()
// Returns: http://laravel.dev 

答案 2

请检查以下内容

$_SERVER['HTTP_HOST'] => Host name from the current request.

$_SERVER['HTTP'] => Set to a non-empty value if the protocol is HTTP

$_SERVER['HTTPS'] => Set to a non-empty value if the protocol is HTTPS

$_SERVER["SERVER_PORT"] => Server port. Default is: 80

$_SERVER['REQUEST_URI'] => The URI to access this page;


推荐