Develdoc:Files

From PMWH2 - PHPMyWebHosting's official wiki
Jump to: navigation, search
up

Your files should start with a notice which includes the copyright, the author, the license and a changelog of this file:

<?php

/**
 * filename.php - <short description in 3-5 words>
 *
 * Copyright (c) <YEAR> by <your name>
 * contributed to PHPMyWebHosting: http://phpmywebhosting.surceforge.net
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 * 
 * <longer description>
 *
 * Changelog:
 * 2004/11/01: <your name>: <describe your changes>
 * 2004/11/02: <your name>: <describe more changes>
 */
 
 if (basename($_SERVER['PHP_SELF'])!="index.php") {
     header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/../index.php");                                          
 }
...

With this notice you show a description of this file, show your copyright on this file and where it belongs to. Also the license you wish to use must appear here. If you code shall go into PHPMyWebHosting only GNU GPL and LGPL are allowed here.

  • The description is important for you (and other developers) if you (or they) want to know what this files does when looking at it after a long time.
  • Also keep the changelog up-to-date so everyone will know what changes were made in this file.
  • The if line makes sure, that mislocated surfers will be redirected to index.php.

Directly after this start with your code. Every file contains only _one_ functionality. Not two or more, only one. This makes maintenance easier.