Hello, I have been trying out the function "header" (to try to avoid caching). The problem is that I do not understand its mechanism of action. Below is a very simple web-page. If the header is included, the webpage will be interpreted as text and "line one" and "line two" will appear on two different lines in the browser. If no header is called the page will be interpreted as HTML and everything will appear on one line in the browser. However, when I look at the source code in the browser, I can only see the text of the page. Nothing is added if I call the function header. What is the mechanism of action of the function header. In the simple example below, how does the function header tell the browser to skip HTML-rendering? Thanks. <? header('Content-type: text/plain'); ?> line one line two Code (markup):
If you don't specify a header, PHP sends a default text/html header. In HTML, a line break, or any amount of spaces or even tabs are treated as a single space. If you want a line break in HTML, you have to use the <br /> tag. If you want more than one space, you have to use .
Thanks nico_swd, (and also thanks for help you gave me in the past) But I still do not understand why I cannot see the header? Shouldn't I be able to see the header when I make ctrl/u in FF (view source). Maybe I don't understand what is included in a header? Nothing changes in the source of the web-page whether I include or do not include this call to function header. How can it then affect the web-page contents?
You cant view php only html source codes, php happens on the server that hosts the files, not in the browser.
Arigatou Kaizoku. With live http headers I can now see many things I wasn't aware of before. I have seen tags like <meta http-equiv="Content-Type" content="text/[B]plain[/B]; charset=utf-8"> Code (markup): But I don't think they work for web-pages, maybe for e-mail? It seems the header is "part of the source code" but cannot be read in the browser without this plug-in. http://en.wikipedia.org/wiki/List_of_HTTP_header_fields Thanks for all the replies.