[英]why require_once just return true, not the array I define;
I was require a file just define a array. 我需要一个文件,只是定义一个数组。 like:
喜欢:
$config = require_once base_path().'/config/webchat.php';
var_dump($config);
exit();
and the webchat.php is just define a array like : 和webchat.php只是定义一个数组,如:
$path = __DIR__.'/../storage/webchat_tmp/';
return [
'path' => $path,
/*
* swoole 配置项(执行主动发消息命令必须要开启)
*/
'swoole' => [
'status' => false,
'ip' => '127.0.0.1',
'port' => '8866',
]
];
the $config was result in a boolean true, not the array. $ config的结果为布尔值true,而不是数组。 could someone tell me why , thanks a lot .
有人能告诉我为什么,非常感谢。 and the path is right.
路径是正确的。 because when I set exit() in the webchat.php .
因为当我在webchat.php中设置exit()时。 it was exit right;
那是出口权;
require_once
return true if file successfully included. 如果成功包含文件,则
require_once
返回true。 But it doesn't return array. 但是它不返回数组。 So you should write following code to have
$config
array in other file. 因此,您应该编写以下代码以在其他文件中具有
$config
数组。 In the other words you add lines of webchat.php
in other file by require_once
it: 换句话说,您可以通过
require_once
在其他文件中添加webchat.php
行:
require_once base_path().'/config/webchat.php';
var_dump($config);
exit();
And 和
$path = __DIR__.'/../storage/webchat_tmp/';
$config = [
'path' => $path,
/*
* swoole 配置项(执行主动发消息命令必须要开启)
*/
'swoole' => [
'status' => false,
'ip' => '127.0.0.1',
'port' => '8866',
]
];
When execute the php code, it seems like this: 当执行php代码时,看起来像这样:
$path = __DIR__.'/../storage/webchat_tmp/';
$config = [
'path' => $path,
/*
* swoole 配置项(执行主动发消息命令必须要开启)
*/
'swoole' => [
'status' => false,
'ip' => '127.0.0.1',
'port' => '8866',
]
];
var_dump($config);
exit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.