Home  >  Article  >  Backend Development  >  请教function里面如何调用外面的数组

请教function里面如何调用外面的数组

WBOY
WBOYOriginal
2016-06-13 12:15:421223browse

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

除了设置全局变量有没有其他的办法或者一般能不能换种方式做??
------解决思路----------------------
作为参数传入
------解决思路----------------------

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

传参
------解决思路----------------------
<br />//a.php页<br />fn();<br />function fn(){<br />include_once 'b.php';<br />print_r($arr);<br />}<br /><br />//b.php页<br />$arr=array(1,2,3,4,5);<br />

以前测试过,好像也可以
------解决思路----------------------
参数,或公共调用接口
你的配置项可以是局部私有的,但必须有开放的接口提供读写

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