IF in PHP does not work [closed]

-2

If I'm on the test / 1 page, it adds the class logoPrincipalHosp to li if not the logoPrincipalElev class.

My PHP:

<li <?php if (preg_match('/teste\/1/')) echo 'class="logoPrincipalHosp"';
else (preg_match('/teste\/2/')) echo 'class="logoPrincipalElev"';
?>>

However, it is not working

    
asked by anonymous 29.01.2015 / 19:44

1 answer

4

If you want to add another condition to be checked in else , then you have to use elseif .

    
29.01.2015 / 20:02