在Laravel中访问$ _GET值的最佳实践是什么? [英] What's the best practice accessing $_GET values in Laravel?

查看:83
本文介绍了在Laravel中访问$ _GET值的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel中访问$_GET而不是变量本身是一种更好的方法吗?

Is there a better way in accessing $_GET rather than the variable itself in Laravel or is that it?

我需要像/users?q=keyword&order=desc&limit=5

是否有一种更干净,更安全和Laravel式的方式来访问$ _GET值?

Is there a cleaner, safer and Laravel-ish way to access the $_GET values?

谢谢.

推荐答案

您可以使用Input门面来达到目标​​.

You can use Input facade to reach those.

您可以执行以下操作:

Input::all();

检索所有查询参数,或者:

to retrieve all of the query parameters, or:

$q     = Input::get('q'); // will return 'keyword' for your example
$order = Input::get('order'); // will return 'desc' for your example
$limit = Input::get('limit'); // will return '5' for your example

这篇关于在Laravel中访问$ _GET值的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆