|
Posted by Kim Andrι Akerψ on 06/01/06 14:44
MS wrote:
> I know this seems simple, but I am totally confused with the following
>
> if(eregi("^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\
> .)|(([ a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email)){
> ....
> }
>
> it supposedly check for a valid email format !!
> But I am getting the impression that this check is not being
> completed.
>
> it makes no difference what the value of $email is I cannot get the
> expression to be True !!
>
> What am I doing Wrong?
Trouble with using ereg() and eregi(), that they return the index
position of the string found, which can be 0, which also can evaluate
as false in an if() statement.
Try adding this before the last closing parethesis above:
!== false
This will make sure that if the string is a valid e-mail adress, the
if-statement will return true. The extra = sign makes sure that "false"
will match on type (boolean) as well as value.
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Navigation:
[Reply to this message]
|