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、配置Gmail邮件客户端的POP3和SMTP
https://www.onexin.net/configure-gmail-e-mail-client-pop3-and-smtp/

2、MySQL数thread_cache和table_cache详解
https://www.onexin.net/the-mysql-the-number-thread_cache-and-table_cache-xiangjie/

3、测试 $_SERVER[“REQUEST_TIME”] 和 time() 记录时间的区别
https://www.onexin.net/server-request_time/

4、SupeSite中用sql调用ecms文章方法
https://www.onexin.net/supesite-using-sql-method-calls-ecms-article/

5、[个人潜能2B]成功的科学条件神经联想之调整(NAC)
https://www.onexin.net/personal-potentials-2b-conditions-for-the-success-of-the-scientific-association-of-neural-adjustment-nac/

Leave a Reply