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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:15:42
Original
1322 people have browsed it

请问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 />
Copy after login

传参
------解决思路----------------------
<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 />
Copy after login

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

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template