将 _POST 参数映射到变量的更好方法
我确信有更好的方法将所有 _POST 参数映射到同名的变量。有人知道如何做得更好吗?
$ownerName = $_POST["ownerName"];
$ownerEmail = $_POST["ownerEmail"];
$ownerPhone = $_POST["ownerPhone"];
$ownerAddress = $_POST["ownerAddress"];
$buyerName = $_POST["buyerName"];
$buyerEmail = $_POST["buyerEmail"];
$buyerPhone = $_POST["buyerPhone"];
$buyerAddress = $_POST["buyerAddress"];
$propertyAddress = $_POST["propertyAddress"];
$parcelNumber = $_POST["parcelNumber"];
非常感谢。
I am sure that there is a better way of mapping all the _POST parameters to variables with the same name. Does anybody know how to do this better?
$ownerName = $_POST["ownerName"];
$ownerEmail = $_POST["ownerEmail"];
$ownerPhone = $_POST["ownerPhone"];
$ownerAddress = $_POST["ownerAddress"];
$buyerName = $_POST["buyerName"];
$buyerEmail = $_POST["buyerEmail"];
$buyerPhone = $_POST["buyerPhone"];
$buyerAddress = $_POST["buyerAddress"];
$propertyAddress = $_POST["propertyAddress"];
$parcelNumber = $_POST["parcelNumber"];
Thanks so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PHP 中有一个函数可以提取值到变量中:
There's a function in PHP to extract the values to vars:
您可以通过这种方式使用 foreach (与
extract
不同,您可以操作/检查变量名称或值You can use a foreach this way (differently from
extract
you can manipulate/check the variable name or the values如果您使用的是 php > 5,我建议看看这个:
http:// www.php.net/manual/en/function.filter-input-array.php
过滤器输入函数允许您轻松应用一些您可能需要的验证和清理。
If you're on php > 5, I would recommend taking a look at this:
http://www.php.net/manual/en/function.filter-input-array.php
The filter input functions allow you to easily apply some validation and sanitation, which you will probably want.