Phpstrpos search-php Tutorial

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.