我有一個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