Reputation: 111
i have this line for validation email and non empty email field:
if ( filter_var($tmpEmail, FILTER_VALIDATE_EMAIL) == TRUE) || (!empty($email)) {
...
}
but i see this error :
Parse error: syntax error, unexpected '||' (T_BOOLEAN_OR) in
how to fix this error?
Upvotes: 0
Views: 535
Reputation: 16495
Try filter_var()
function from the PHP manual, which can manipulate/validate strings orders.
$email = '[email protected]';
if ((filter_var($email, FILTER_VALIDATE_EMAIL) == TRUE) || !empty($email)) {
// your email is correct.
}
Upvotes: 0
Reputation: 1240
The )
after TRUE
ends the if
statement, remove that and the (
before !empty
.
Upvotes: 2
Reputation: 27227
Your parentheses are mismatched. Try:
if ( filter_var($tmpEmail, FILTER_VALIDATE_EMAIL) || !empty($email)) {
Upvotes: 2