String values CS Coding Standards

From: Date: Tue, 18 Jan 2005 22:20:55 +0000
Subject: String values CS Coding Standards
Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-2339@lists.php.net to get a copy of this message
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 &#039 or double &#034 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)

« previous php.pear.qa (#2339) next »