Авторизация
 Регистрация   Войти   Забыли пароль? 

Function and Method Declaration

:: English Support Forums :: PHP-Fusion Coding Coding Style :: Function and Method Declaration
Admin  Распечатать сообщение

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:
Загрузить источник  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:
Загрузить источник  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.
Загрузить источник  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. ?>

Изменил(а) Admin , 04.06.2013 20:54:02
  Опубликовано 04.06.2013 20:52:59 
 Перейти на форум:   
HTML-code and BB-code for blogs and forums

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


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

Голосования
Надо сделать новое название для форума?
Не покупаю ссылки
Не покупаю ссылки
100% = [2 Голосов]
"СТАТЕЙНЫЕ" СПОСОБЫ
"СТАТЕЙНЫЕ" СПОСОБЫ
0% = [0 Голосов]
Зависит от к-ва выпитого :)
Зависит от к-ва выпитого :)
50% = [1 Голос]
15
15
0% = [0 Голосов]
Нах надо !
Нах надо !
50% = [1 Голос]
Нах надо !
Нах надо !
100% = [2 Голосов]
не знаю
не знаю
50% = [1 Голос]
Всего голосов : 2
Перейти в ветку