php header location vs php_redirect

后端 未结 3 1475
广开言路
广开言路 2021-01-06 02:19

What\'s the difference between the function \"HTTP_redirect\" and \"header location\" in PHP ?

When must I use the function \"HTTP_re

3条回答
  •  悲哀的现实
    2021-01-06 02:40

    1) Header in PHP

    header() function sends a raw HTTP header to a client.

    
    

    The above (taken from the PHP documentation) sends a 404 header back to the client.

    2) HTTP Redirect

    Redirect to the given url.

     "value"), true, HTTP_REDIRECT_PERM);
    ?>
    

    The above (taken from the PHP documentation) : Output

    HTTP/1.1 301 Moved Permanently
    X-Powered-By: PHP/5.2.2
    Content-Type: text/html
    Location: http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc
    
    Redirecting to http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc.
    

提交回复
热议问题