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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 14:54:07
Original
1201 people have browsed it

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 of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template