In PHP what is the difference between using \1 or $1 as $replacement in preg_replace()?
They both work and seem to do the exact same thing, but I think I’m missing something here.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re not missing anything. There is only one situation where $n only can be used:
Aside from that, there is absolutely no difference between the two.