Using single or double quotation marks comes from the PHP language, usually their characteristics are:
Double quotes:
-
A little slower, so try to process data
-
read variables within it, eg "hi $ name"
-
allows escape characters, such as: "hi on another line"
Single quotes:
- A bit faster, because it is treated as a string, regardless of whether there are any escape or variables present in it.
The only difference that can occur is that by giving single quotes you will not have the '\' character and escape, so it would be safer to use double quotation marks.
In the first example:
// Single quoted string
preg_match('/\/path\/to\/folder\//', $path)
// Double quoted string
preg_match("/\/path\/to\/folder\//", $path)
It would be:
/\/path\/to\/folder\//
//path/to/folder//
In short, PHP will treat the string according to the quotes used, in the first nothing changes because it does not perform any treatment, as the second is in single quotation marks, there is treatment, which in this case would be the characters of escapes, so the string would look like it was previously.