Using single or double quotes comes from the PHP language, usually their characteristics are:
Double quotes:
a little slower as it tries to process data
reads variables enter it, example: "hi $name"
allows escape characters such as: "hi on another line"
Single quotes:
- a little faster, as it is treated as a string, regardless of whether there are escapes or variables present in it.
The only difference that can occur is that by giving simple quotes you will not have the character and escape ' ', then it would be safer to use double quotes.
In the first example:
// Single quoted string
preg_match('/\/path\/to\/folder\//', $path)
// Double quoted string
preg_match("/\/path\/to\/folder\//", $path)
Seria:
/\/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 between simple quotes, there is treatment, in case it would be the characters of escapes, then the string would be the form previously passed.
Man, perfect, explains exactly what will be the Regex and still a toast a Good Practice.
– Machado