Wednesday, April 14, 2010

PHP - zend framework coding standars

Looking into the zend framework I noticed their coding standards at

http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html#coding-standard.php-file-formatting.max-line-length

Far as I'm concern looks very good to me (except perhaps the auto loading as this can be done in different ways).

The autoload function can be then done like this:


function __autoload($class)
{
      $file = str_replace('_','/',substr($class,2)).'.php';    
      require_once(FR_BASE_PATH.'/includes/'.$file);
  }

or like where you can change the $parts and $path with more options


function __autoload($class)
{
  $parts = explode('_', $class);
  $path = implode(DIRECTORY_SEPARATOR, $parts);
  require_once (DIRECTORY_SEPARATOR .  $path . '.php');
}