This document describes the PHP script file conventions for the Campcaster
project. See also the generic description of the file conventions in the Campcaster
project.
A PHP script containing only class definition should have filename which reflects the class,
it is implementing.
Class names begin with a capital letter, followed by lower case letters.
In case of a multiple word file name, the first letter of each word is
capitalized.
Other PHP scripts should have name starting with lowecase letter.
PHP script files are named by the following rules:
there are no spaces in the file name
for file names containing multiple words, each additional word
begins with a capital letter
the extension of the file is .php
Structure
PHP scripts are partitioned by using the following 80 column wide partitioning comments:
/* ==================================================== name of the partition */
and
/* ------------------------------------------------- name of the subpartition */
The file has the following mandatory structure:
PHP starting tag <?php
Header
Defines ?
Include files ?
Code sections +
PHP ending tag ?>
Because PHP is in-HTML embedable script language, it is possible to mix PHP and HTML code
using PHP tags <?php and ?>. This mixing approach is little bit
obsolete and it is better to use pure PHP (with structure described above) and some template system to generate HTML.
Header
The header holds all information mandated by the generic guidelines, but
are enclosed in the PHP multiline comments /* */. Note the 80
column wide partitioning delimiter enclosing the header.
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
https://www.campware.org/
To report bugs, send an e-mail to [email protected]
Campcaster is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Campcaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: paul $
Version : $Revision: 2373 $
Location : $URL: svn://code.campware.org/campcaster/trunk/campcaster/doc/developmentEnvironment/phpFileConventions.html $
------------------------------------------------------------------------------*/
Defines
This section contains all the constant defines, similar as:
define('CONSTAT_NAME', 10);
Include files
This section contains all the include files that the script needs
to include.
The include files are listed in
a most generic to most specific order: first PEAR classes, then
other Campcaster module include files, and finally include files from
the same module / product are listed.
Is much safer to use include_once or require_once, not the original versions
of this statement.
Code sections
This sections contain class definitions, function definitions or runable PHP commands.