Переключатель дизайна
Bordur2-Bogatyr

Language: English (en)
 Russian Russian   English English 

Function and Method Declaration

:: English Support Forums :: PHP-Fusion Coding Coding Style :: Function and Method Declaration
Admin  Print Post

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39

Function and Method Declaration
PHP-Fusion Coding Style PHP-Fusion version 7.02.00



Functions must be named according to PHP-Fusion's funcEon naming convenEons. Methods inside
classes must always declare their visibility by using one of the private, protected, or public
modi.ers. As with classes, the brace should always be wriLen on the same line as the funcEon
name. Space between the funcEon name and the opening parenthesis for the arguments is not
permiLed.
FuncEons in the global scope are strongly discouraged.
The following is an example of an acceptable funcEon declaraEon in a class:
Download source  PHP
  1. <?php
  2.  class MyClass {
  3.   // Method description here
  4.   public function myFunction() {
  5.    // all contents of function
  6.    // must be indented by one tab
  7.   }
  8.  }
  9. ?>


In cases where the argument list exceeds the maximum line length, you may introduce line breaks.
AddiEonal arguments to the funcEon or method must be indented one addiEonal level beyond the
funcEon or method name. A line break should then occur before the closing argument parent,
which should then be placed on the same line as the opening brace of the funcEon or method with
one space separaEng the two, and at the same indentaEon level as the funcEon or method
declaraEon. The following is an example of one such situaEon:
Download source  PHP
  1. <?php
  2.  class MyClass {
  3.  // Method description here
  4.   public function myFunction($arg1, $arg2, $arg3,
  5.         $arg4, $arg5, $arg6) {
  6.    // all contents of function
  7.    // must be indented one tab
  8.   }
  9.  }
  10. ?>

The return value must not be enclosed in parentheses. This can hinder readability, in addiEonal to
breaking code if a method is later changed to return by reference.
Download source  PHP
  1. <?php
  2.  class MyClass {
  3.   // WRONG
  4.   public function myFunction() {
  5.    return($this->value);
  6.   }
  7.  
  8.   // RIGHT
  9.   public function myFunction() {
  10.    return $this->value;
  11.   }
  12.  }
  13. ?>

Edited by Admin on 04.06.2013 20:54:02
  Posted on 04.06.2013 20:52:59 
 Jump to Forum:   
HTML-code and BB-code for blogs and forums

<a href="https://php-fusion.vveb.ws/forum/viewthread.php?lang=en&thread_id=151">Function and Method Declaration : Function and Method Declaration</a>


[url=https://php-fusion.vveb.ws/forum/viewthread.php?lang=en&thread_id=151]Function and Method Declaration : Function and Method Declaration[/url]

Голосования
Можно я не буду проводить тут подобный опрос?
Всего голосов : 1
Перейти в ветку