我有一个PHP文件中的类的数组,这个类有3个字段,我使用这些字段来保存SELECTS和INPUT CHECKBOX在FORM内部使用POST,然后我需要将这个类的数组发送到另一个用于处理数据的php文件。如何发送一个PHP数组类的值从一个PHP文件到另一个PHP文件
<?php
class info_subject{
public $code_as;
public $time_as;
public $selectionn_as;
}
$subjects[0] = new info_subject();//The only way I have seen for creating an array of classes
//is with a for loop, but if you have a better way for doing this, please let me know
$subjects[1] = new info_subject();
//here i am using the fields to save info in a form
$i=0;
echo "<form name = 'formsubjects' method='post' action='file2.php'>";
echo "<select name=\"".$subjects[$i]->time_as ."\">";
//options
echo "</select>";
echo "<input type='checkbox' name=\"".$asignaturas[$i]->selection_as."\">";
//and so on with every position of the array using $i
?>
//then there is a button to send the the dato to file2.php
//file2.php
<?php
$subjects=$_POST["$subjects"];//I am using this but i cant retrieve the fields of $subjects
?>
我该怎么办好友?
你绝对应该看看MVC架构。 – 2014-09-24 01:08:24
什么是好友?... – 2014-09-24 01:10:51
一种编程方式,不会让你像HTML那样混合使用HTML,也就是说,它不能解决你的问题。对于你的问题,我建议你创建一个方法返回你需要的变量,然后在你的其他文件中使用你的类,并调用你刚刚实现的函数 – 2014-09-24 01:21:47