The code in the PHPstrstr function book is not understood.

Source: Internet
Author: User
The code in the PHPstrstr function book does not understand the code in the book about strstr. it is searched based on the submitted feedback and sent to unused emails.
$ Totaladress = 'destback @ example.com '; if (strstr ($ feedback, 'shop') {$ totaladress = 'retail @ example.com ';} else {$ totaladress = 'account @ example.com ';}

I have read the description on w3school. after strstr finds the target string, it returns the remaining part, that is, the string. Otherwise, it returns false. what is the meaning of the function return value directly used as the if judgment condition?
Thank you for your explanation.


Reply to discussion (solution)

The strstr () function searches for the first occurrence of a string in another string.
This function returns the rest of the string (from the matching point ). If the searched string is not found, false is returned.

Echo strstr ("Hello world! "," World ");
?>
Output:
World!

If is determined, it is converted into a boolean string = true in brackets.
You can understand it as a shorthand
$ A = strstr ($ feedback, 'shop ');
If ($! = False ){}

If is determined, it is converted into a boolean string = true in brackets.
You can understand it as a shorthand
$ A = strstr ($ feedback, 'shop ');
If ($! = False ){}


Thank you. after reading your answer, I went to the internet to check it again. I understand.

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.