I read in the manual that \\1 and $1 are the same.
Original words from the manual: Replacement can contain back references \\n or $n, and the latter is preferred grammatically. Each such reference will be replaced by the text captured by the matching nth capturing subgroup. n can be 0-99, \\0 and $0 represent the complete pattern matching text. The serial number counting method of capturing subgroups is: the left bracket representing the capturing subgroup is counted from left to right, starting from 1. If you want to use backslashes in replacement, you must use 4 ("\\\\", translator's annotation: Because this is first a PHP string, after escaping, there are two, and then after passing through the regular expression engine is considered a text backslash).
replyIf we talk about the difference, it is: preg_replace() We don’t know whether we want to express \\11 or \\1 1 (the second 1 is the string 1). So using ${1}1 can let preg_replace() know that the first 1 is a backreference, and the second 1 is just the 1 of the original text immediately following the backreference.
I read in the manual that \\1 and $1 are the same.
Original words from the manual: Replacement can contain back references \\n or $n, and the latter is preferred grammatically. Each such reference will be replaced by the text captured by the matching nth capturing subgroup. n can be 0-99, \\0 and $0 represent the complete pattern matching text. The serial number counting method of capturing subgroups is: the left bracket representing the capturing subgroup is counted from left to right, starting from 1. If you want to use backslashes in replacement, you must use 4 ("\\\\", translator's annotation: Because this is first a PHP string, after escaping, there are two, and then after passing through the regular expression engine is considered a text backslash).