简体   繁体   中英

Respect/Validation email() don't work

I use Respect/Validation and when I use email()...the problem is:

if I validate a string: validator::email()->validate('hello@helloworld.com'); it work!

if I validate a variable: validator::email()->validate($_POST['email']); it doesn't work!

I try to check the content into $_POST['email'] and it's: hello@helloworld.com

the exact output of var_dump($_POST['email']); is: string(21) " hello@helloworld.com"

As you can see in the output of var_dump($_POST['email']) , there is a whitespace in front of the email address:

string(21) " hello@helloworld.com"

So you have to remove that from your parameter, eg with trim() :

validator::email()->validate(trim($_POST['email']));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM