Novice@PHP Posted December 8, 2010 Share Posted December 8, 2010 I keep getting an "Unknown modifier" error with this line of code in my script: $ret = @preg_replace('«'.stripslashes($pattern).'«i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); The error says there is a '�' character but when I check the file there are none of them present in the code, though first time I chekced there were then I removed them but error still occurs. preg_replace() [function.preg-replace]: Unknown modifier '�' Is there a case that it is not refreshing the script and I need to delete and replace? (tried this though) Is there an issue with the initial line of code I've shown? (it has worked for weeks up until I changed memory size scripts are allowed to use). The weird issue is that no matter how many times I change the line to the previously working line - the script will still encounter the issue...? All replies thanked in advance and I'll pop back soon to see any suggestions. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/ Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 I think you're using a character set that's not supported. Why are you using that character as a delimiter anyway? («) Also, remove the '@' symbol. Suppressing errors isn't healthy, if you have errors you should handle them appropriately. Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144635 Share on other sites More sharing options...
Novice@PHP Posted December 8, 2010 Author Share Posted December 8, 2010 I think you're using a character set that's not supported. Why are you using that character as a delimiter anyway? («) Also, remove the '@' symbol. Suppressing errors isn't healthy, if you have errors you should handle them appropriately. The weird part is this script worked fine, then where the («) are was replaced with those weird question marks so I replaced with the backed up file but still get those errors saying they still exist when they don't any more? Could the script possibly have cached an old version of the way it runs? Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144638 Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 I think you're using a character set that's not supported. Why are you using that character as a delimiter anyway? («) Also, remove the '@' symbol. Suppressing errors isn't healthy, if you have errors you should handle them appropriately. The weird part is this script worked fine, then where the («) are was replaced with those weird question marks so I replaced with the backed up file but still get those errors saying they still exist when they don't any more? Post your current code. Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144639 Share on other sites More sharing options...
Novice@PHP Posted December 8, 2010 Author Share Posted December 8, 2010 $ret = preg_replace('«'.stripslashes($pattern).'«i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); Could it have cached the file it is using and is still using an old version with the weird question marks? As it's this same error over and over again even though the weird question marks are not in the code any more? Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144640 Share on other sites More sharing options...
salathe Posted December 8, 2010 Share Posted December 8, 2010 You can't use multibyte unicode characters (« is \u00AB) as delimiters for your pattern. See http://php.net/regexp.reference.delimiters Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144641 Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 You can't use multibyte unicode characters (« is \u00AB) as delimiters for your pattern. See http://php.net/regexp.reference.delimiters This. I just told you that character is not supported. Look at Salathe's link: Often used delimiters are forward slashes (/), hash signs (#) and tildes (~). Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144646 Share on other sites More sharing options...
Novice@PHP Posted December 8, 2010 Author Share Posted December 8, 2010 You can't use multibyte unicode characters (« is \u00AB) as delimiters for your pattern. See http://php.net/regexp.reference.delimiters This worked fine up until an hour ago when the "«" was replaced with '�' and it created the error. I then fixed the line but it still keeps saying that the '�' is causing an "Unknown modifier" even though the '�' doesn't even exist in the code any more... ? Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144647 Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 You can't use multibyte unicode characters (« is \u00AB) as delimiters for your pattern. See http://php.net/regexp.reference.delimiters This worked fine up until an hour ago when the "«" was replaced with '�' and it created the error. I then fixed the line but it still keeps saying that the '�' is causing an "Unknown modifier" even though the '�' doesn't even exist in the code any more... ? The code you pasted still had it. Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144651 Share on other sites More sharing options...
Novice@PHP Posted December 8, 2010 Author Share Posted December 8, 2010 The code you pasted still had it. This code has worked fine for months: $ret = @preg_replace('«'.stripslashes($pattern).'«i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); Then the error was saying that this character '�' found in the code (even in notepad) like this: $ret = @preg_replace(''�'.stripslashes($pattern).''�i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); (had to leave off php tags to show it properly). So I replaced the broken code with the code that has been working for months, but it still keeps saying that the '� is on that line and casuing an unknown modifier?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144657 Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 Please listen. Use this code: $ret = preg_replace('~'.stripslashes($pattern).'~i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144660 Share on other sites More sharing options...
Novice@PHP Posted December 8, 2010 Author Share Posted December 8, 2010 Please listen. Use this code: $ret = preg_replace('~'.stripslashes($pattern).'~i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); I'm testing this now, hopefully it works, but what I don't understand is why would it have worked all these months then just stopped? Thanks all, I'll come back after rigorous testing Quote Link to comment https://forums.phpfreaks.com/topic/221063-constannt-unknown-modifier-error-even-though-i-fixed-it-multiple-times/#findComment-1144664 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.