hunglduc Posted April 5, 2009 Share Posted April 5, 2009 why if statement if executed but else statement not executed. $str="welcome to php"; if(ereg("[^a-z]",$str)) echo "don't appear<br />"; else echo "appear<br />"; Link to comment Share on other sites More sharing options...
jlhaslip Posted April 5, 2009 Share Posted April 5, 2009 The If clause is activated when the If statement is true.The else clause is only activated when the If statement is false.Only one of them should work. Link to comment Share on other sites More sharing options...
Synook Posted April 5, 2009 Share Posted April 5, 2009 I think he's asking why that regular expression matches. The reason is, you are asking whether there are any non-alphabetic characters in the string "welcome to php", and since the spaces " " are not included in the set [a-z] the expression matches those and returns true. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.