gpt4 book ai didi

PHP htmlspecialchars 错误

转载 作者:搜寻专家 更新时间:2023-10-31 20:56:26 26 4
gpt4 key购买 nike

为什么会这样

$trader_details = array_walk($trader_details, 'htmlspecialchars');

给这个错误?

Severity: Warning
Message: htmlspecialchars() expects parameter 2 to be long, string given

afaik htmlspecialchars 除了输入字符串之外只有可选参数?这在 codeigniter 中运行

谢谢

最佳答案

传递给 array_walk 的回调函数期望第二个参数是数组元素的键:

Typically, funcname takes on two parameters. The array parameter's value being the first, and the key/index second.

但是htmlspecialchars期望第二个参数是引用样式(通常由整数类型的 ENT_* constants 之一指定)。

尝试 array_map反而。它只使用数组的值。

关于PHP htmlspecialchars 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1317063/

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