当我使用此代码时,它会显示正确的结果
<?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
?>
但是当我将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
?>
为什么两种结果都不同......?感谢。