Home  >  Article  >  Backend Development  >  请问function里面怎么调用外面的数组

请问function里面怎么调用外面的数组

WBOY
WBOYOriginal
2016-06-23 13:39:111248browse

请问function里面怎么调用外面的数组,数组内容主要是配置信息。

除了设置全局变量有没有其他的办法或者一般能不能换种方式做??


回复讨论(解决方案)

作为参数传入

$arr=array(1,2,3,4,5);$arr2 = test($arr);function test ($get_arr){return $get_arr;}

传参

//a.php页fn();function fn(){include_once 'b.php';print_r($arr);}//b.php页$arr=array(1,2,3,4,5);

以前测试过,好像也可以

参数,或公共调用接口
你的配置项可以是局部私有的,但必须有开放的接口提供读写

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn