How to remove HTTP headers from CURL response?

前端 未结 10 1150
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 17:26

I have a php script that returns just plain text without any html. Now I want to make a cURL request to that script and I get the following response:

<
10条回答
  •  眼角桃花
    2020-12-13 17:35

    If someone already saved the curl response to a file (like me) and therefore don't know how big the header was to use substr, try:

    $file = '/path/to/file/with/headers';
    file_put_contents($file, preg_replace('~.*\r\n\r\n~s', '', file_get_contents($file)));
    

提交回复
热议问题