문제

What PHP function or encoding method could allow you to convert an email address to a set of characters, then decoded again when needed? The email address would be publicly available to a certain program/audience, which handles conversions, but would not be harvested by spammers due to not being recognized as an email address.

Obviously it would have to have a perfect 1 to 1 conversion.

도움이 되었습니까?

해결책

You can do web safe encode and decode using this

// encode emailaddress
$email_encoded = rtrim(strtr(base64_encode($email), '+/', '-_'), '=');

 // decode email address
$email_decoded = base64_decode(strtr($email_encoded, '-_', '+/'));

It converts the + and / from the base64 alphabet in the more harmless - and _. The encoding step also removes the trailing = characters when needed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top