Re: String values CS Coding Standards

From: Date: Wed, 19 Jan 2005 01:20:40 +0000
Subject: Re: String values CS Coding Standards
References: 1  Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-2340@lists.php.net to get a copy of this message
the speed issue between ' and " should have been pretty much removed now, even though I've been using it for a long while, I'd be tempted to suggest starting to follow other language standards: eg. 'x' for single characters "long strings" enclosed in double quotes. Basically my PHP habits are a pain when working with C and C#.. But I'll survive if nothing changes ;) Regards Alan bertrand Gugger wrote:
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. à+


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