Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to validate a given URL using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 360
    Comment on it

    Hello reader! If you have a to check the url is correct or not (not giving the status 404), Then you can get all the details of any url by using 'get_headers' in print_r. Let's see the example below:-0

    <?php
     stream_context_set_default(
        array(
            'http' => array(
                'method' => 'HEAD'
            )
        )
    );
    print_r(get_headers('http://example.com'));
    
    // Output:-
    Array
    (
        [0] => HTTP/1.1 200 OK 
        [Date] => Sat, 29 May 2004 12:28:14 GMT
        [Server] => Apache/1.3.27 (Unix)  (Red-Hat/Linux)
        [Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT
        [ETag] => "3f80f-1b6-3e1cb03b"
        [Accept-Ranges] => bytes
        [Content-Length] => 438
        [Connection] => close
        [Content-Type] => text/html
    )
    

    Now you see in the output [0] => HTTP/1.1 200 OK So by this way you have all the details of any url and check with the several parameters.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: