[TYPO3-dev] [TYPO3-core] New TYPO3 Coding Guidelines

Ries van Twisk typo3 at rvt.dds.nl
Mon Jul 13 19:58:25 CEST 2009


On Jul 13, 2009, at 12:18 PM, Bastian Waidelich wrote:

> Mathias Schreiber [wmdb >] wrote:
>
>
>> "One strlen can't hurt"
>
> I would never claim this..
> But.. Even though
> if (!isset($text{5})) echo 'text too short';
> is faster than
> if (strlen($text) < 5) echo 'text too short';
>
> I'd go for the strlen() variant unless it's a really critical part of
> the code. Just because it's more readable and meaningful (In this  
> case a
> goo PHP optimizer will do the rewriting anyways).
>
> Just my 2ct
> Bastian


You wouldn't want to go for critical parts aswell.
strlen will be multibyte in PHP6 and thus
much more compatible with PHP5,
trying to check if the 5th BYTE has something is dangerous
and might result in unexpected outcomes, specially for MB strings.

My advice, stick to standards and leave optimizations to the byte  
compiler.

Ries








More information about the TYPO3-dev mailing list