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';}?> Link to comment https://forums.phpfreaks.com/topic/297083-elseif-statement-issue/ Share on other sites More sharing options...
Ch0cu3r Posted June 28, 2015 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 Link to comment https://forums.phpfreaks.com/topic/297083-elseif-statement-issue/#findComment-1515149 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 . Link to comment https://forums.phpfreaks.com/topic/297083-elseif-statement-issue/#findComment-1515182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.