Home  >  Article  >  Backend Development  >  PHP determines whether a variable contains (includes) a specific string_PHP tutorial

PHP determines whether a variable contains (includes) a specific string_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:54:071118browse

Question:

php determines whether a variable contains (includes) a specific string

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

How to make the program make the following judgment:

If there is "exe" in $liehuo_net, then output "EXE"

If there is no "exe", determine whether there is "123"
If there is "123", output "one two three"

If not, output "none"

Answer:


$liehuo_net="123456789.exe";

if(strstr($liehuo_net,"exe"))
{
echo "exen ";
}
elseif(strstr($a,"123"))
{
echo "one two three n";
}
else
{
echo "Nothing";
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364664.htmlTechArticleQuestion: PHP determines whether a variable contains (includes) a specific string. If there is a variable $liehuo_net=123456789.exe, how to make it The program makes the following judgment: If there is an exe in $liehuo_net, output the EXE. If there is not...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn