Formats des fichiers

Tous les scripts apportés à PEAR doivent :

  • Etre stocké comme du texte ASCII

  • Utiliser le jeux de caractères ISO-8859-1

  • Etre formaté Unix

    Le "formatage Unix" signifie deux choses :

    1) Les lignes doivent finir uniquement par un retour à la ligne (LF). Les retours à la ligne sont représentés par l'ordinal 10, l'octal 012 et l'hexa 0A. N'utiliser pas les retours carriage (CR) comme le font les Macintosh ou les combinaisons de retour carriage/retour à la ligne (CRLF) comme le fait Windows.

    2) Il ne doit y avoir qu'un seul retour à la ligne après la fermeture du tag PHP (?>). Cela signifie que lorsque le curseur est à la fin du fichier, il doit y avoirune seule après le tag PHP fermant.

Conventions de Nom (Previous) E_STRICT-compatible code (Next)
Last updated: Sun, 29 Aug 2010 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by:
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, 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:
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?