For phpstrpos search, you need to call strpos to find the substrings in a string.
function canFindApn($line,$apnName){$pos=strpos($line2, $apnName);if ($pos!==false){ echo $line2." contains".$apnName."
";return true;}else{echo $line2." not contains".$apnName."
";return false;}
If the parameter is directly written to a string, canFindApn ("abcdefg", "efg") is no problem. if I call this function through another function and pass the string, the returned value is incorrect, I also try to write a function by myself, and the return value is always false when calling. it is okay to directly write the string.
If I want to call this method to determine whether the substring exists in the string, how should I write it?
Reply to discussion (solution)
No way. paste the code you called to see it.
Add a sentence in this function, echo the specific values of $ line2 and $ apnName to see what is passed in. if it is a string, it should not be wrong.
You can post the code you called.
Your code won't get the correct result at any time!
Function canFindApn ($ line, $ apnName ){
$ Pos = strpos ($ line2, $ apnName );
Where does $ line2 come from?
Your code won't get the correct result at any time!
Function canFindApn ($ line, $ apnName ){
$ Pos = strpos ($ line2, $ apnName );
Where does $ line2 come from?
++
The passed parameter $ apnName is added at the end.
. The echo print page cannot be seen, but the source code of the webpage can be seen.
Thank you for your help!