| bertrand Gugger 2005-01-18, 8:58 pm |
| Hi QA folks,
So far I can check, PEAR's CS in manual dont give any advice for the
string values.
It gave some discussions about use simple ' or double "
quotation mark.
Obviously PHP kernel loose a little time with double.
But it's quite no debate compared to what it does overall.
Anyway the advice could be:
Simple when it is static (expected never dynamic)
as e.g. an associaive array index as $this->param['setting']
or to initialize a string as $string = '';
Double when content (is expected to) contain variable or escape (\n) to
interpret.
When not obvious (?) then free ' or "
Some people mentioned to choose simple or double once for the whole script.
I will not agree, and I believe it's making no difference for tokenizers.
What should be a rule is the surrounding (brackets) around variables
within double:
never "Hello $name" but "Hello {$name}"
because;
- "Hello $name are you OK ?" could become "Hello $nameare you OK ?"
but "Hello {$name}are you OK ?" still works (I18N)
- or "Hello $name[$i]" should be "Hello {$name[$i]}"
as $name can become $name[$i] or $this->name or ...
It's awfull to type once but value for future maintenance.
This advice is in PHP manual since a long time.
Hope some of you can agree.
Ã_+
--
bertrand Gugger (toggg)
|