Get Content-Type of requested url in php

后端 未结 3 1824
不知归路
不知归路 2020-12-11 10:01

Using php how would I be able to define the variable $type into the content-type of http://www.example.com

For example: $type

3条回答
  •  没有蜡笔的小新
    2020-12-11 10:31

    Not very clear on what you are trying to do, but if you are trying to get the request content type that was sent by the browser to your script, you can do this:

     $header){
        $headers[strtolower($name)] = $header;
    }
    
    // Get the content type header
    $contentType = $headers['content-type'];
    ?>
    

提交回复
热议问题