gpt4 book ai didi

php - 为什么我不能将 'require' 与 'array_map' 一起使用?

转载 作者:行者123 更新时间:2023-12-01 08:54:50 26 4
gpt4 key购买 nike

我已尝试包含文件列表中的内容:

$files = [
'a.php',
'b.php',
];
$contents = array_map('require', $files);

但这没有用。我得到的错误是:

Warning: array_map() expects parameter 1 to be a valid callback, function 'require' not found or invalid function name

为什么会这样?有没有办法让它发挥作用?

最佳答案

因为 require 不是函数,它是一种语言结构。

您需要创建一个有效的回调函数来执行实际的需求,或者使用自动加载器

关于php - 为什么我不能将 'require' 与 'array_map' 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29412329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com