0

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?

3 Answers 3

2

Your parentheses are mismatched. Try:

if ( filter_var($tmpEmail, FILTER_VALIDATE_EMAIL) || !empty($email)) {
Sign up to request clarification or add additional context in comments.

Comments

2

The ) after TRUE ends the if statement, remove that and the ( before !empty.

Comments

0

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. 
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.