Dareros Posted September 18, 2014 Share Posted September 18, 2014 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 Link to comment https://forums.phpfreaks.com/topic/291138-single-quote-and-double-quotes-difference/ Share on other sites More sharing options...
.josh Posted September 18, 2014 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. 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. 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
Archived
This topic is now archived and is closed to further replies.