filter_var() 함수는 지정된 필터로 변수를 필터링하는 데 사용됩니다.
구문
filter_var(variable, filter, options)
매개변수
-
변수 − 변수 이름.
-
필터 − ID를 가져올 필터의 이름입니다.
-
옵션 − 사용할 옵션을 지정합니다.
반환
filter_var() 함수는 성공 시 필터링된 데이터를 반환하고 실패 시 거짓을 반환합니다.
예시
<?php $myEmail = "[email protected]"; if (filter_var($myEmail, FILTER_VALIDATE_EMAIL { echo("$myEmail = valid email address"); } else { echo("$myEmail = invalid email address"); } ?>
출력
다음은 출력입니다.
[email protected] = valid email address