The below will search for the occurrence of CUST_LOOKUP_EDIT in a string of CUST_LOOKUP_EDIT,EMAIL_DIST_EDIT and of course this does exist and exists at the first occurrence but this is then returned as 0 which can be viewed as being false.
So the below will FAIL as it will return 0;
$a = 'CUST_LOOKUP_EDIT,EMAIL_DIST_EDIT';
if (strpos($a, 'CUST_LOOKUP_EDIT') == true) {
echo 'true';
}
we can prove this by running echo (strpos($a, 'CUST_LOOKUP_EDIT'));
which will return 0 as it is the first occurrence.
so to find out if it exists at all, we need to change it to the below;
$a = 'CUST_LOOKUP_EDIT,EMAIL_DIST_EDIT';
if (strpos($a, 'CUST_LOOKUP_EDIT') !== false) {
echo 'true';
}
NOTE: the !== false
No comments:
Post a Comment
Note: only a member of this blog may post a comment.