警告:strpos()最多需要3个参数,23在第9行的page.php中给出

时间:2016-03-31 05:22:24

标签: php strpos

1.列表项

if (strpos($page_name_ulter, 'dissertation' ||  $page_name_ulter, 'vendor' || $page_name_ulter, 'js' || $page_name_ulter, 'css' || $page_name_ulter, 'bootstrap' || $page_name_ulter, 'CI3Xmuqx6MsCFcJf2wod6s0P9Q' ||   $page_name_ulter, 'vendor' || $page_name_ulter, 'vendor' || $page_name_ulter, '=' ||   $page_name_ulter, 'essay?' ||   $page_name_ulter, 'input' ||   $page_name_ulter, 'main.js' || $page_name_ulter, 'main' || $page_name_ulter, 'php/js' || $page_name_ulter, '/' || $page_name_ulter, '.js' || $page_name_ulter, 'rating' || $page_name_ulter, 'intlTelInput' || $page_name_ulter, '.min' || $page_name_ulter, 'images') !== false) { return false; }

5 个答案:

答案 0 :(得分:1)

你已经这样做了

if (strpos($page_name_ulter, 'dissertation') !== false ||  strpos($page_name_ulter, 'vendor')!== false  and so on

答案 1 :(得分:1)

您需要知道 strpos()功能的基本信号。

strpos(字符串,发现,启动)

但在你的情况下,你只传递 strpos()函数中的条件。 多数民众赞成错误..

检查此

if (strpos($page_name_ulter, 'dissertation') !== false ||  strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, 'js') !== false || strpos($page_name_ulter, 'css') !== false || strpos($page_name_ulter, 'bootstrap') !== false || strpos($page_name_ulter, 'CI3Xmuqx6MsCFcJf2wod6s0P9Q') !== false ||strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, '=') !== false || strpos($page_name_ulter, 'essay?') !== false || strpos($page_name_ulter, 'input') !== false || strpos($page_name_ulter, 'main.js') !== false || strpos($page_name_ulter, 'main') !== false || strpos($page_name_ulter, 'php/js') !== false || strpos($page_name_ulter, '/') !== false || strpos($page_name_ulter, '.js') !== false || strpos($page_name_ulter, 'rating') !== false || strpos($page_name_ulter, 'intlTelInput') !== false || strpos($page_name_ulter, '.min') !== false || strpos($page_name_ulter, 'images') !== false) { return false; }

答案 2 :(得分:1)

PHP strpos不适用于单个strpos函数中的多个(OR / ||)条件。

根据文档:strpos查找字符串中第一次出现子字符串的位置

要使其有效,您需要多个strpos IF声明

if (
strpos($page_name_ulter,'dissertation') !== false || 
strpos($page_name_ulter,'vendor') !== false
) {

echo 'Founded';
}

答案 3 :(得分:1)

由于strpos()不适用于多个&& OR ||条件,因此您需要添加)strpos!== false,如下所示:

if (strpos($page_name_ulter, 'dissertation') !== false ||  strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, 'js') !== false || strpos($page_name_ulter, 'css') !== false || strpos($page_name_ulter, 'bootstrap') !== false || strpos($page_name_ulter, 'CI3Xmuqx6MsCFcJf2wod6s0P9Q') !== false ||strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, 'vendor') !== false || strpos($page_name_ulter, '=') !== false || strpos($page_name_ulter, 'essay?') !== false || strpos($page_name_ulter, 'input') !== false || strpos($page_name_ulter, 'main.js') !== false || strpos($page_name_ulter, 'main') !== false || strpos($page_name_ulter, 'php/js') !== false || strpos($page_name_ulter, '/') !== false || strpos($page_name_ulter, '.js') !== false || strpos($page_name_ulter, 'rating') !== false || strpos($page_name_ulter, 'intlTelInput') !== false || strpos($page_name_ulter, '.min') !== false || strpos($page_name_ulter, 'images') !== false) { return false; }

有关功能的更多详细信息: - http://php.net/manual/en/function.strpos.php

注意: - 更好的解决方案是使用preg_match()

检查手册: - http://php.net/manual/en/function.preg-match.php

答案 4 :(得分:1)

正如其他人提到的那样,您应该知道<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app = "app"> <div ng-controller="Main"> <div > <table class="table table-bordered"> <tr ng-repeat="d in data | filter: {completed: false }"> <td>{{d.content}}</td> </tr> </table> </div> </div> </div>期望的内容,请看一下:strpos 以下建议是减少对strpos的许多函数调用

因为你有很多不同的价值观,我建议其他方法。如果你的字符串只包含你要搜索的值,我会去一个数组,条件可以使用strpos if (in_array($ultravariable, $arrayWithPossibleValues)) { }应该是您正在搜索的包含wach值的数组。

如果您正在搜索的字符串(超变量)确实包含更多数据,但您只需要检查它是否以不同的值开头,那么我会选择$arrayWithPossibleValues

preg_match 在这里,您可以使用value1,value2等替换可能的值,并记住将它们与if ( preg_match("/^(value1|value2|value3)/", $ultravariable)) { }分开。

希望这有帮助