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

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

随机文章:

1、Data URI scheme
https://www.onexin.net/data-uri-scheme/

2、用js实现sleep, 用php实现parseInt
https://www.onexin.net/use-js-to-achieve-sleep-use-php-to-achieve-parseint/

3、自动获取“省-市-县-乡镇”地址 For UCH 2.0
https://www.onexin.net/automatically-selects-the-province-city-county-township-address/

4、Magento中如何调用SQL语句
https://www.onexin.net/how-to-call-sql-statements-magento/

5、wp_list_categories如何隐藏子分类咧?
https://www.onexin.net/how-do-i-hide-sub-categories-wp_list_categories-decide/

Leave a Reply