happy cat image

everdevel

coding

login
NotificationX
  • Currently, only notices of comments are displayed.
  • no comment or please login
























Thank you for visiting My Web Site

Validate url

Let's see how to validate a url.
Use the filter_Var() built-in function.
And use the constant FILTER_VALIDATE_URL as argument.

How to validate URLs using filter_Var()

filter_Var('URL',FILTER_VALIDATE_URL);

The first argument uses the URL address, the second uses the constant FILTER_VALIDATE_URL.
As shown in the example, you can change the purpose according to the value of a constant.
Returns true if the URL address is valid or false.
Here is an example of URL validation:

<?php
    $url = "https://www.everdevel.com";

    $checkUrl = filter_Var($url, FILTER_VALIDATE_URL);

    if($checkUrl == true) {
        echo "correct URL";
    } else {
        echo "not correct URL";
    }
?>

I'll check the results right below.

Result

이번에는 틀린 URL 주소를 입력해서 테스트 해봅시다.

<?php
    $url = "www.everdevel.com";

    $checkUrl = filter_Var($url, FILTER_VALIDATE_URL);

    if($checkUrl == true) {
        echo "correct URL";
    } else {
        echo "not correct URL";
    }
?>

I'll check the results right below.

result


Thank you for visiting. If you have any inquiry or explanation of mistakes, please use the comments below.

컨텐츠의 내용을 더 보려면 바로 아래에서 확인할 수 있습니다.


    
    

Back to the course

ALL COMMENTS 0

Sort by