Php determines whether a variable contains (including) a specific string _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php determines whether a variable contains (including) a specific string. Problem: phpbench variables include: how does one make the program Judge liehuo_net123456789.exe when there is an exe in $ liehuo_net? Problem:

Php determines whether a variable contains (including) a specific string

If there is a variable
$ Liehuo_net = "123456789.exe"

How to let the program make the following judgment:

If $ liehuo_net contains "exe", "EXE" is output"

If no "exe" exists, check whether "123" exists"
If "123" is available, "one, two, three" is output"

If no, the output is "none"

Answer:


$ Liehuo_net = "123456789.exe ";

If (strstr ($ liehuo_net, "exe "))
{
Echo "exe \ n ";
}
Elseif (strstr ($ a, "123 "))
{
Echo "one, two, three \ n ";
}
Else
{
Echo "none ";
}

?>

Php determines whether the variable contains (including) a specific string. if there is a variable named $liehuo_net%123456789.exe, how can the program make the following judgment: if $ liehuo_net contains exe, the output EXE is not...

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.