Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $\u会话是否启动所有$\u POST变量?_Php_Syntax_Post_While Loop - Fatal编程技术网

Php $\u会话是否启动所有$\u POST变量?

Php $\u会话是否启动所有$\u POST变量?,php,syntax,post,while-loop,Php,Syntax,Post,While Loop,有没有办法对每个post变量执行某种while(),并将其会话起来。。。就像mysql一样 while($row=mysql_fetch_array($result)){ echo($row['name']; } 但是要想通过$u POST获得这个结果 while($_POST){ $_SESSION['BLA'] = $_POST['BLA']; } 此方法更可取,因为它意味着您的帖子信息存储在子数组中,因此不会替换您可能已经存在的任何其他会话元素。此方法更可取,因为它意味着您的帖子信息存

有没有办法对每个post变量执行某种
while()
,并将其会话起来。。。就像mysql一样

while($row=mysql_fetch_array($result)){
echo($row['name'];
}
但是要想通过$u POST获得这个结果

while($_POST){
$_SESSION['BLA'] = $_POST['BLA'];
}

此方法更可取,因为它意味着您的帖子信息存储在子数组中,因此不会替换您可能已经存在的任何其他会话元素。此方法更可取,因为它意味着您的帖子信息存储在子数组中,因此不会替换您可能已经存在的任何其他会话元素。
foreach($_POST as $i=>$v){
    $_SESSION[$i] = $_POST[$i];
}
foreach($_POST as $key => $value){
echo $key . ' = ' .$value. ' <br />';
 // do whatever you want to do with these variables
}
$_SESSION['MyPost'] = $_POST;