mkHun mkHun - 1 year ago 71
Perl Question

Why use `\n` in CGI script while printing header?

In CGI script, on the top the program we use the:

print "Content-type: text/html\n\n";
without using
it will not execute. But, inside the HTML body, we do not use
can't make any sense, for new line we use

is necessary in the header line?

Answer Source

Content-type: text/html is the HTTP header, not HTML. For detecting the end of HTTP header must be one empty line. First \n for end of current line, second \n for new empty line.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download