[英]Call an array including into another file with php
Why this do not work and how can I solve it please ? 为什么这不起作用,请问如何解决?
Main page: 主页:
$a = include 'module_a.php';
print_r($a);
module_a.php page: module_a.php页面:
function go() {
include 'datas.php';
return $array;
}
datas.php page: datas.php页面:
$array = array();
$array[10] = 'bla';
$array[11] = 'blo';
return $array;
I do not have any error in the console except that no code is print. 除了没有打印代码外,我在控制台中没有任何错误。
Thanks for your help. 谢谢你的帮助。
I suppose it should be somehow like this: 我想应该是这样的:
include 'module_a.php';
$a = go();
print_r($a);
To your post update: datas.php doesn't have to return $array
对您的帖子更新:datas.php不必返回$array
Nothing is printed because you define function go
but you never execute it. 什么都不会打印,因为您定义了function go
但是您从不执行它。 Do: 做:
include 'module_a.php';
print_r(go());
You forgot to call go
function 你忘了打电话go
功能
index.php index.php
<?php
$a = include 'module_a.php';
print_r($a);
module_a.php module_a.php
function go() {
include 'datas.php';
return $array;
}
return go();
datas.php datas.php
<?php
$array = array();
$array[10] = 'bla';
$array[11] = 'blo';
return $array;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.