[英]strpos function is not working correctly when i use true in condition why?
When i am using this code it show me correct result 当我使用此代码时,它会向我显示正确的结果
<?php
$string = 'there is some text';
$find = 'some';
function iscontain($string,$find){
$check = strpos($string, $find);
if ($check === false) { return 0; }else{ return 1; }
}
if(iscontain($string,$find)){
echo "true";
}else{
echo "false";
}
//output: true
?>
But when i change false into true and also change return values like if check is true so return 1 else 0 so logically is correct but result not showing correct 但是当我将false更改为true时,还更改了返回值,例如check是否为true,因此返回1 else 0,因此在逻辑上是正确的,但结果未显示正确
<?php
$string = 'there is some text';
$find = 'some';
function iscontain($string,$find){
$check = strpos($string, $find);
if ($check === true) { return 1; }else{ return 0; }
}
if(iscontain($string,$find)){
echo "true";
}else{
echo "false";
}
//output : false
?>
Why both results are different ..? 为什么两个结果都不同..? Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.