PHP Coding Standard

Logo: PHP
6. Regel 3: Jede PHP-Datei muss das Copyright und einen Kommentar enthalten, der die Funktionalität beschreibt

Der C++ Coding Standard geht davon aus, dass in jeder Datei mit Source Code auch der Dateiname erwähnt wird. Dieses Konzept erscheint mir unlogisch, weil der Dateiname beim Bearbeiten und Drucken bekannt sein sollte. Trotzdem steht es jedem Entwickler frei, den Dateinamen mit in den Kopf einer Datei aufzunehmen.

Gültig
   // +----------------------------------------------------------------------+
   // | Copyright (c) 2002-2006 Claus van Beek <cvb@nospam.net>              |
   // +----------------------------------------------------------------------+
   // | This describes the following script. Basic information is provided.  |
   // | "LAN" = Local Area Network. Other Abbrivations are not used in this  |
   // | script.                                                              |
   // +----------------------------------------------------------------------+
   // | This library is free software; you can redistribute it and/or        |
   // | modify it under the terms of the GNU Lesser General Public           |
   // | License as published by the Free Software Foundation; either         |
   // | version 2.1 of the License, or (at your option) any later version.   |
   // +----------------------------------------------------------------------+

Das Copyright sollte zur Wahrung der eigenen Rechte oder der gewählten Lizenz in jeder PHP-Datei erwähnt werden. Wurde das Produkt über mehrere Jahre entwickelt, dann sollte jedes Jahr erwähnt werden.

Wenn viele Autoren an einem Projekt arbeiten und auch noch verschiedene Lizenzen im Spiel sind (wie bei PEAR) ist es unter Umständen sinnvoll, folgende Version zu verwenden:

Gültig
   /**
    * Crypt_Blowfish allows for encryption and decryption on the fly using
    * the Blowfish algorithm. Crypt_Blowfish does not require the mcrypt
    * PHP extension, it uses only PHP.
    * Crypt_Blowfish support encryption/decryption with or without a secret key.
    *
    *
    * PHP versions 4 and 5
    *
    * LICENSE: This source file is subject to version 3.0 of the PHP license
    * that is available through the world-wide-web at the following URI:
    * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
    * the PHP License and are unable to obtain it through the web, please
    * send a note to license@php.net so we can mail you a copy immediately.
    *
    * @category   Encryption
    * @package    Crypt_Blowfish
    * @author     Matthew Fonda <mfonda@nospam.net>
    * @copyright  2005 Matthew Fonda
    * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
    * @version    CVS: $Id: Blowfish.php,v 1.81 2005/05/30 18:40:36 mfonda Exp $
    * @link       http://pear.php.net/package/Crypt_Blowfish
    */

Diesen Eintrag kann man mit Tools wie Javadoc, Doxygen oder phpDocumentor auswerten. Da sich die meisten Menschen zuerst mit einer Dokumentation auseinandersetzen, bevor sie den Source-Code durcharbeiten, ist eine API-Referenz oft hilfreich.