[TYPO3-core] Double backslash for namespace

Xavier Perseguers xavier at typo3.org
Tue Jun 17 11:12:57 CEST 2014

Hi Bernhard,

> I would like to ask if it is really necessary (according to the CGL) to
> have double backslash in namespaces. Whenever the single quote string
> style is used it is not necessary regarding PHP syntax.
> So:
> $someObject = GeneralUtility::makeInstance('TYPO3\CMS\SomeObject');
> Would be fully valid. Double backslashes are not required. I guess they
> were introduced because the "\" operator is known to be the escape
> operator. But in case it is followed by any non-escape character it
> won't do anything. Only if combined with special meaning characters like
> "\n", "\r", "\x" they will get interpreted - and this also only in
> double quoted strings.
> So if we stick to single-quoted strings as usual in TYPO3 world it would
> be ok to have only one backslash.

Yes you can abuse the PHP syntax so you may instead write only one
backslash but in Core we want to stick to strict rules so this character
should be escaped as well.


Xavier Perseguers
TYPO3 CMS Team Member

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org

More information about the TYPO3-team-core mailing list