Jus*_*ser 21 php laravel laravel-routing laravel-5
我有多个引导选项卡,其中每个选项卡执行与其他选项卡不同的操作
app-url/users#creat-admin-users-tab app-url/users#creat-regular-users-tab
在Laravel中有没有办法获得包括#tab-name在内的完整URL
谢谢你的时间.
And*_*ius 64
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
Run Code Online (Sandbox Code Playgroud)
小智 5
检查以下内容
$_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;
确实如此 - 目前获取“#”的唯一方法是使用 js,例如:
var hash = window.location.hash;
var tabName1 = '#creat-admin-users-tab';
var tabName2 = '#creat-regular-users-tab';
if (hash.indexOf(tabName1) !== -1) console.log("It's creat-admin-users-tab");
else if (hash.indexOf(tabName2) !== -1) console.log("It's creat-regular-users-tab");
Run Code Online (Sandbox Code Playgroud)
这可以帮助您处理 url 的其他部分(将其添加到您的路由文件中):
use Illuminate\Http\Request;
Route::get('/app-url/users', function (Request $request) {
$fullUrl = $request->fullUrl();
var_dump($fullUrl);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33086 次 |
| 最近记录: |