phpBB Coding Guidelines

Working with placeholders:
As phpBB is translated into languages with different ordering rules to that of English, it is possible to show specific values in any order deemed appropriate. Take for example the extremely simple “Page X of Y“, whilst in English this could just be coded as:

	...
'PAGE_OF'	=>	'Page %s of %s',
		/* Just grabbing the replacements as they
		come and hope they are in the right order */
	...

… a clearer way to show explicit replacement ordering is to do:

	...
'PAGE_OF'	=>	'Page %1$s of %2$s',
		/* Explicit ordering of the replacements,
		even if they are the same order as English */
	...

Why bother at all? Because some languages, the string transliterated back to English might read something like:

	...
'PAGE_OF'	=>	'Total of %2$s pages, currently on page %1$s',
		/* Explicit ordering of the replacements,
		reversed compared to English as the total comes first */
	...

Use of in_array():

Try to avoid using in_array() on huge arrays, and try to not place them into loops if the array to check consist of more than 20 entries. in_array() can be very time consuming and uses a lot of cpu processing time. For little checks it is not noticable, but if checked against a huge array within a loop those checks alone can be a bunch of seconds. If you need this functionality, try using isset() on the arrays keys instead, actually shifting the values into keys and vice versa. A call to isset($array[$var]) is a lot faster than in_array($var, array_keys($array)) for example.

http://area51.phpbb.com/docs/coding-guidelines.html

随机文章:

1、Android手机应用开发环境搭建
https://www.onexin.net/android-phone-application-development-environment-to-build/

2、使用ie7.js来解决ie6兼容问题
https://www.onexin.net/use-ie7-js-to-solve-the-problem-of-ie6-compatible/

3、javascript单引号和双引号的区别以及使用方法
https://www.onexin.net/javascript-single-and-double-quotes-and-use-the-difference-between/

4、Discuz!X修复门户下载图片换行丢失BUG
https://www.onexin.net/discuzx-portal-downremoteimg-bug/

5、迅雷thunder://地址与普通url地址转换
https://www.onexin.net/thunder-thunder-address-and-general-url-address-translation/

转载请注明出处:https://www.onexin.net/phpbb-coding-guidelines/

Leave a Reply

Your email address will not be published. Required fields are marked *