From 53726213051a996b6379aea3f872bf49218d6c14 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Mon, 5 Nov 2018 13:24:12 +0100 Subject: [PATCH] Updated Strings (markdown) --- Strings.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Strings.md b/Strings.md index 67860cf..bcebc1f 100644 --- a/Strings.md +++ b/Strings.md @@ -1,3 +1,5 @@ +# Whenever possible use single quote strings + PHP supports both single quote strings and double quote strings. For pure text you must use single quote strings for consistency. Double quote strings are only allowed for special characters (i.e. `"\n"`) or inlined variables (i.e. `"My name is {$name}"`);
Example

@@ -18,7 +20,7 @@ echo 'Hello World!'; _Reference_: [`Squiz.Strings.DoubleQuoteUsage`](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php) -*** +# Add spaces around the concatenation operator The concatenation operator should have one space on both sides in order to improve readability. @@ -61,7 +63,7 @@ $text = $greeting _Reference_: [`Squiz.Strings.ConcatenationSpacing`](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php) -*** +# Use a single string instead of concatenating While concatenation is useful for combining variables with other variables or static text. It should not be used to combine two sets of static text. See also: [Maximum line length](Maximum-line-length)