what is difference between header and include, where which one should be used

前端 未结 8 1871
我在风中等你
我在风中等你 2021-02-07 18:58

I am confused with two terms

  1. header (\"Location:homepage_php\");

  2. include(\"homepage.php\");

I am g

8条回答
  •  名媛妹妹
    2021-02-07 19:24

    The header function is used to send raw HTTP headers back to the client: PHP header function

    
    

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

    The include function is used to include files into the current PHP script (the same as require) PHP include function

    vars.php

    
    

    test.php

    
    

    This example (again from the PHP documentation) includes the vars.php script in the test.php script and, after the include, allows the test.php script to access the variables declared in the vars.php script.

提交回复
热议问题