I have a problem using preg_match. (I’m very new to regular expressions)
if(preg_match('^/http:\/\/myWebsite\.com\/', $_SERVER['HTTP_REFERER'])) {
return true;
}
else{
return false;
}
Always returns false and it shouldn’t. Where am I wrong?
UPDATE
Hi everybody ! Thanks all of you for your help ! Every check is fine now
Your regular expression is missing the delimiters, as PHP should have warned you:
… triggers:
Since you are allowed to choose your own delimiter, it’s simpler to pick one that’s not in the text:
Additionally, if the text is not fixed (not this case I presume), PHP can escape it for you:
I suggest you configure your development box to display all possible errors. You have several ways to do so:
Edit your
php.inifile:Put this on top of your script:
If PHP runs as Apache module, you can also use an
.htaccessfile: