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

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

WBOY
Release: 2016-06-23 13:39:11
Original
1318 people have browsed it

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

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


回复讨论(解决方案)

作为参数传入

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

传参

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

以前测试过,好像也可以

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

source:php.cn
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