-1
我不能为我的生活弄清楚为什么被抛出这个错误...我提供一个有效的数组,它仅仅是一个基本的循环PHP无效参数提供
PHP
class stats {
private $resirictedChars = array('@', '(', ')', '"', '<', '>', ',', '?', ':', ';', '[', ']', '{', '}');
function __construct() {}
public function generateStats ($text) {
foreach ($this->restrictedChars as $char) {
$text = str_replace($char, '', strtolower($text));
}
echo $text;
}
}
$run = stats::generateStats('hello.');
错误
Warning: Invalid argument supplied for foreach()
检查名称,它们不匹配:'$ resirictedChars'!=='$ restrictedChars' – 2013-05-13 18:51:36
您在初始化数组时名称错误。 – andrewsi 2013-05-13 18:51:44
它总是最愚蠢的东西......谢谢你haha – user2359318 2013-05-13 18:52:19