Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:28:33+00:00 2026-06-12T19:28:33+00:00

Suppose a file saved on the disk: HTTP/1.1 200 OK Date: Thu, 28 Jun

  • 0

Suppose a file saved on the disk:

HTTP/1.1 200 OK
Date: Thu, 28 Jun 2012 22:11:14 GMT
Pragma: no-cache
Cache-Control: must-revalidate, no-store
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 1234
Connection: close
Content-Type: text/html

<html ....

Is there any builtin function in php to output the file while at the same time recognizing headers inside it and sending them correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:28:34+00:00Added an answer on June 12, 2026 at 7:28 pm

    It does not exists but you can use the following

    $file = "file.html";
    var_dump(fileHeaders($file));
    

    Output

    array
      0 => string 'HTTP/1.1 200 OK' (length=15)
      1 => string 'Date: Thu, 28 Jun 2012 22:11:14 GMT' (length=35)
      2 => string 'Pragma: no-cache' (length=16)
      3 => string 'Cache-Control: must-revalidate, no-store' (length=40)
      4 => string 'Expires: Thu, 01 Jan 1970 00:00:00 GMT' (length=38)
      5 => string 'Content-Length: 1234' (length=20)
      6 => string 'Connection: close' (length=17)
      7 => string 'Content-Type: text/html' (length=23)
      8 => string '' (length=0)
    

    Function Used

    function fileHeaders($file) {
        $content = file_get_contents($file, null, null, 0, 1000);
        $content = trim($content);
        if (stripos($content, "HTTP") === 0) {
            return array_map("trim", explode("\n", strtok($content, "<")));
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I remember that I saved a word XYZword to some file in a
Suppose we have the following HTML file: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test iframe download</title> <script
suppose i have saved file path in database. now i want to show those
How to load javascript contents using php. Suppose when php saves a file using,
suppose file has contents as A=abc, B=fl, C=asd A=59, B=sadl, C=asd A=ab40c, B=sad, C=asd
I want to split a file(suppose a mp3) into four parts.I have tried this
I am implementing a file sharing system in ASP.NET MVC3. I suppose most file
Suppose I have file which goes like this : a void measure() { a
Suppose I have a Javascript file function js_main(args){ /* some code */ var x
Suppose I have a file containing some lines: line 1 ... line 2 ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.