General PHP coding standards for Elxis CMS
The instructions listed here are important in order for the source code to be clear, easy to understand, well organized and be able to function under all enviroments and web servers. So we suggest to everyone who would like to be a part of elxis developers keep this notes as guidelines.
On the very top of all Elxis php file we place the following code:
<?php /** * @version $Id$ * @package Elxis * @subpackage If any, write the subpackage here, else ommit this line * @copyright Copyright (c) 2006-2012 Elxis CMS (http://www.elxis.org). All rights reserved. * @license Elxis Public License ( http://www.elxis.org/elxis-public-license.html ) * @author Elxis Team ( http://www.elxis.org ) * @description Elxis CMS is free software. Read the license for copyright notices and details */ defined('_ELXIS_') or die ('Direct access to this location is not allowed.');
Important note
We do not set Id property on files encoded as UTF-8 such as language files! We write instead the Elxis version the file is for (for example ''2011.0'')
The subpackage line can be ommitted if it is a general file that has a global scope and not specific area of interest. ''subpackage'' values can be strings like this: ''Database'' (for a database related file), ''Component Documentor'' for a files belonging to component Documentor'', etc.
Wrong example:
$test[] = 5; $test[] = 6;
Correct example:
$test = array(); $test[] = 5; $test[] = 6;
$test = new myClass($arg1, $arg2); $test->doSomething(); unset($test);
Slower method:
$test = array(); array_push($test, 'mercedes'); array_push($test, 'bmw');
Faster method:
$test = array(); $test[] = 'mercedes'; $test[] = 'bmw';
function test($arguments) { //function contents }
function test($argument1, $argument2, $argument3) { }
function testName() {} function otherTestName() {}
private function test() {} public function test2() {} static public function test3() {}
/*******************/ /* RESIZE AN IMAGE */ /*******************/ function resizeImage($arguments) { //function contents }
defined('_ELXIS_') or die ('Direct access to this location is not allowed.');
Κατασκευάστε μηχανές που επεκτείνουν την αναζήτηση του elxis οπουδήποτε μπορείτε να φανταστείτε