Simple PHP If / ElseIf statement not working
This question already has an answer here:
You are using =
instead of ==
for the last cases.
This will always be true since this is an assignation.
Replace those by ==
and you're good to go.
Careful with = and == . I think that is the problem.
if ( $title == 'New York' )
{
echo 'This is New York';
}
elseif ( $title == 'California' )
{
echo 'This Is California';
}
else if ($title == "Chicago" )
{
echo 'This is Chicago';
}
else if ($title == "Seattle" )
{
echo 'This is Seattle';
}
else
{
echo 'No Match Found';
}
you have to be careful for ==
because =
will not work properly in if condition for comparison every time
use == for string and === if numeric
链接地址: http://www.djcxy.com/p/58456.html