PHP extract()函数
2012-07-11 17:16
134 查看
extract -- 从数组中将变量导入到当前的符号表
看到一个非常好用的函数:extract(),它的主要作用是将数组展开,键名作为变量名,元素值为变量值,可以说为数组的操作提供了另外一个方便的工具,比方说,可以很方便的提取$_POST或者$_GET的元素,对表单提交上来的内容不能不用一一赋值,直接使用下面代码:
form.html
<form action="action.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit">
在action.php中只要使用extract()函数将$_POST全局数据解开:
action.php
<?php
extract($_POST);
//相当于$username = $_POST[username];
//$password = $_POST[password];
?>
看到一个非常好用的函数:extract(),它的主要作用是将数组展开,键名作为变量名,元素值为变量值,可以说为数组的操作提供了另外一个方便的工具,比方说,可以很方便的提取$_POST或者$_GET的元素,对表单提交上来的内容不能不用一一赋值,直接使用下面代码:
form.html
<form action="action.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit">
在action.php中只要使用extract()函数将$_POST全局数据解开:
action.php
<?php
extract($_POST);
//相当于$username = $_POST[username];
//$password = $_POST[password];
?>
相关文章推荐
- PHP extract() 函数
- PHP extract 将数组拆分成多个变量的函数
- VBScript版的PHP extract()函数
- PHP extract() 函数
- PHP extract() 函数
- PHP extract() 函数
- PHP extract() 函数
- PHP extract() 函数的用法
- PHP extract() 函数
- PHP extract 将数组拆分成多个变量的函数
- PHP extract() 函数
- PHP extract 将数组拆分成多个变量的函数
- PHP extract() 函数
- 乐杨俊:PHP extract() 函数
- PHP extract() 函数
- PHP extract() 函数
- php extract 函数的妙用 数组键名为声明为变量,键值赋值为变量内容
- 陆续一些常用函数汇编实现
- [原创]18行代码实现无限级填充TreeView的例子与函数