AbeerSaba Posted June 28, 2015 Share Posted June 28, 2015 hi all , i am a new php learner i tried to make my 1st elseif statement i ran into a syntax error , tried several options non worked , would you please help ?! the code is below & i cant seems to work this issue any help is highly appreciated .<?php$name = ' sara ' ;if ( $name == 'New York' ){echo 'This is New York';}elseif ( $name == 'sara' ){ echo ' hi sara ' ; }else{echo 'No Match Found';}?> Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted June 28, 2015 Solution Share Posted June 28, 2015 When you define $name it is defined as (space)sara(space) the elseif will never match due to the name being padded with spaces. == does an exact match. Either remove the spaces or apply trim to $name Quote Link to comment Share on other sites More sharing options...
AbeerSaba Posted June 29, 2015 Author Share Posted June 29, 2015 you are a time saver !! thannnk you funny how i tried everything & missed this tiny clue . Appreciated . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.