PHP GET Request, sending headers

前端 未结 3 1279
刺人心
刺人心 2020-12-02 23:24

I need to perform a get request and send headers along with it. What can I use to do this?

The main header I need to set is the browser one. Is there an easy way to

3条回答
  •  旧巷少年郎
    2020-12-02 23:45

    You can use the header function for that, example:

    header('Location: http://www.example.com?var=some_value');
    

    Note that:

    Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

提交回复
热议问题