File Formats

All scripts contributed to PEAR must:

  • Be stored as ASCII text

  • Use ISO-8859-1 or UTF-8 character encoding. The encoding may be declared using declare(encoding = 'utf-8'); at the top of the file.

  • Be Unix formatted

    "Unix formatted" means two things:

    1) Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.

    2) There should be one line feed after the closing PHP tag (?>). This means that when the cursor is at the very end of the file, it should be one line below the closing PHP tag.

Naming Conventions (Previous) E_STRICT-compatible code (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

Note by: gbarnhardt@gmail.com
I thought that any whitespace after the closing php tag ?> causes errors. Additionally, isn't best practice to not include the closing php tag at all?
Note by: kornel
I don't like these rules.

You require @author tag, and my name cannot be properly written in ASCII or ISO-8859-1. I think requirement of UTF-8 is much more reasonable these days.

Although "?>\n" is harmless, any accidentally added lines after that will be output and will cause trouble. I don't see any benefit in having "?>" and I see potential pitfalls, so IMHO it should be forbidden, rather than required.

Note by: wiesemann
shiplu.net..., you're wrong. The described line feeds are intended to not cause trouble e.g. with the header() or with session functions. Problems would arise only if there would be any more whitespace after the closing tag.
Note by: shiplu.net@gmail.com
LF after ?> is not a good idea.
It'll cause problem while working with headers.
I think this rule should be omitted.
Note by: gauthierm
cbrunet: Adding a single line-feed after the closing ?> does not cause headers to be sent. It is ignored by PHP.
Note by: cbrunet
Adding a LF after the last ?> could cause a problem to scripts that need to be executed before headers are sent. I will send a newline to the browser, causing headers to be send.
Note by: Dev
Whay not use the unicode utf-8 format?