diff options
author | Marc Alexander <admin@m-a-styles.de> | 2018-01-07 11:02:31 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-01-07 11:02:31 +0100 |
commit | 1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99 (patch) | |
tree | d70037f3f547a71e4a6b87bcddb31aeb19db7328 /phpBB/docs/coding-guidelines.html | |
parent | 3ae016954212e90032a10d1427c34a4ff9d9637c (diff) | |
parent | 182a96f2738316adcb292816a9ac8af0e0cb5866 (diff) | |
download | forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.gz forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.bz2 forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.xz forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.zip |
Merge remote-tracking branch 'upstream/3.2.x' into prep-release-3.2.2
Diffstat (limited to 'phpBB/docs/coding-guidelines.html')
-rw-r--r-- | phpBB/docs/coding-guidelines.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index d90f4d4d32..569ffe680c 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -627,7 +627,7 @@ $min = ($i < $j) ? $i : $j;</pre> <pre>if (isset($forum) && $forum == 5)</pre> </div> - <p>The <code>empty()</code> function is useful if you want to check if a variable is not set or being empty (an empty string, 0 as an integer or string, NULL, false, an empty array or a variable declared, but without a value in a class). Therefore empty should be used in favor of <code>isset($array) && sizeof($array) > 0</code> - this can be written in a shorter way as <code>!empty($array)</code>.</p> + <p>The <code>empty()</code> function is useful if you want to check if a variable is not set or being empty (an empty string, 0 as an integer or string, NULL, false, an empty array or a variable declared, but without a value in a class). Therefore empty should be used in favor of <code>isset($array) && count($array) > 0</code> - this can be written in a shorter way as <code>!empty($array)</code>.</p> <h4>Switch statements:</h4> <p>Switch/case code blocks can get a bit long sometimes. To have some level of notice and being in-line with the opening/closing brace requirement (where they are on the same line for better readability), this also applies to switch/case code blocks and the breaks. An example:</p> @@ -994,9 +994,9 @@ $sql = $db->sql_build_query('SELECT', $sql_array);</pre> <h4>Operations in loop definition: </h4> <p>Always try to optimize your loops if operations are going on at the comparing part, since this part is executed every time the loop is parsed through. For assignments a descriptive name should be chosen. Example:</p> - <p class="bad">// On every iteration the sizeof function is called</p> + <p class="bad">// On every iteration the count function is called</p> <div class="codebox"><pre> -for ($i = 0; $i < sizeof($post_data); $i++) +for ($i = 0; $i < count($post_data); $i++) { do_something(); }</pre> @@ -1004,7 +1004,7 @@ for ($i = 0; $i < sizeof($post_data); $i++) <p class="good">// You are able to assign the (not changing) result within the loop itself</p> <div class="codebox"><pre> -for ($i = 0, $size = sizeof($post_data); $i < $size; $i++) +for ($i = 0, $size = count($post_data); $i < $size; $i++) { do_something(); }</pre> |