ベストプラクティス
PEAR コーディング規約でカバーされていない問題もまだありますが、
それらの多くは個人的な好みの問題であり、コードの可読性とは直結しません。
「シングルクォートとダブルクォートのどちらを使用するか」
などといった問題は、プログラミングを簡単にするための
PHP の機能そのものについてものであり、どちらを選ぶとかいう類のものではありません。
このような、いわゆる「ベストプラクティス」については各開発者にお任せします。
ただ、各パッケージ内では一貫性を保つようにしてください。また、
他の開発者の個人的なスタイルを尊重することも大切です。
エラー処理の指針 (Previous)
|
(Next) サンプルファイル (標準の Docblock コメントを含む)
|
|
|
Download Documentation
|
Last updated: Sun, 21 Jun 2009 |
|
Do you think that something on this page is wrong? Please file a bug report or add a note.
|
| User Notes: |
Note by: bobvandell@hotmail.com
Try this site to check the speed of single quotes versus double quotes:
http://www.phpbench.com
I've found that it has a lot of best practices to help you out as well.
One major one for me was counting the length of a loop before hand instead of doing it inline:
$len = count($arr);
for ($i = 0; $i < $len; $i++)
{
// Code
}
Is faster than
for ($i = 0; $i < count($arr); $i++)
{
// Code
}
Note by: natecmichael@gmail.com
Micro-optimization like "single quotes are faster" is unnecessary!
Note by: Maga
Interpolation makes script slower, it matters! Single quotes are faster!
Note by: Leonardo Herrera
Double quotes interpolate, single quotes don't. Isn't this important?
|
|