【发布时间】:2013-01-22 18:23:49
【问题描述】:
我有这样的功能:
function form($filename){
$text="";
if (file_exists(dirname(__FILE__)."/other/".$filename)){
ob_start();
include "other/".$filename;
$text = ob_get_clean();
}
return $text;
}
而且,在我的代码中,我有类似的东西:
class First {
public function execute()
$an_array=array("hi","goodbye");
return form("my_form.php");
}
现在我想知道如何在“my_form.php”上获取$an_array 的值。
函数form 将与可能需要多个变量的其他文件一起使用。
编辑
我希望包含的文件可以读取多个参数。换句话说,在其他课程上,我可以有这样的东西:
class Second {
public function execute()
$first_array=array("hi","goodbye");
$second_array=array("other","another");
return form("another_form.php");
}
在这种情况下,我想在我的another_form.php 文件中同时读取$first_array 和$second_array。
编辑 2
有什么方法可以让我的 form 函数像 php 的 array_push 函数一样工作?换句话说,我想在form 上有第二个参数,它的作用类似于array_push 的最后一个参数。
【问题讨论】:
标签: php function variables parameters include