Dareros Posted September 18, 2014 Share Posted September 18, 2014 (edited) Is there a difference between a single quote regex and and double quote regex ? for example : <?php $res1 = preg_match('/shi*t/', $comment); $res2 = preg_match("/shi*t/", $comment); ?> Thank you Edited September 18, 2014 by Dareros Quote Link to comment https://forums.phpfreaks.com/topic/291138-single-quote-and-double-quotes-difference/ Share on other sites More sharing options...
Solution .josh Posted September 18, 2014 Solution Share Posted September 18, 2014 In that example, there is no difference. http://php.net/manual/en/language.types.string.php for reference on the difference between single vs. double quotes. 1 Quote Link to comment https://forums.phpfreaks.com/topic/291138-single-quote-and-double-quotes-difference/#findComment-1491469 Share on other sites More sharing options...
Jacques1 Posted September 18, 2014 Share Posted September 18, 2014 There are no “single-quoted regexes” or “double-quoted regexes”. What you have there are two different string expressions which are parsed according to the usual rules. In your case, the result is the same. The content of the string is then used as a regex. If the conents were different, then of course you'd have two different regexes. But since the content is the same, it's the same regex, regardless of whether it comes from a single-quoted string or a double-quoted string. 1 Quote Link to comment https://forums.phpfreaks.com/topic/291138-single-quote-and-double-quotes-difference/#findComment-1491470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.