php vs txt display - courier and times
Why is it when I upload a plain text file to a server, it displays (in Safari) using the couri开发者_运维知识库er font, and when I output from a php it shows as Times?
Plain text is plain text. It carries no formatting information of its own, and the browsers will decide how to display it. Displaying a file directly, the web server will supply it with a mime type text/plain
. This will often instruct the browser to use a fixed width font (Courier). But if you output it with PHP, the server is sending it as text/html
(HTML) and the browser is using its default font for HTML (Times, in your case).
For the plain text, you don't have any control over how the end user's browser will render it. That setting is entirely up to browser defaults or user preferences. Of course, you can influence how it is displayed as HTML when output by PHP with CSS declarations.
That's because of Content-type
HTTP header.
It's text/plain
in case of txt file and text/html
with php
Web-server do check mime-type of the file (judging by extension) and send appropriate header.
That's specified by your browser. You can setup that within your browsers settings if you prefer other fonts. What you describe is a common setup.
The server is only specifying the so called content-type, text/plain
for the text-file, text/html
for the php page.
The user uses the browser to display them accordingly, like the font and it's size. If you add CSS to your html output and the user allows your website to provide CSS for displaying purposes (which is quite common as well), then the CSS style information will be used which could change the font and size.
精彩评论