Suppose, you have some rules to check whitelisted url. So everytime whenever you will get a new url so you can cross match that URL with your whitelisted URL. And whitelisted URLs sometimes can be wildcard url. So to check whether the given URL matched any of the wildcard urls. <?php $whiteListedUrls = [ "https://google.com/test/*", "https://yahoo.com/test/index.html", "https://sohelrana.me/*", "https://sohelrana.me" ]; $url = "https://google.com/test/testWildCard/ok.html"; function checkUrlWildcard($url, $whiteListUrls = []) { foreach ($whiteListUrls as $wUrl) { $pattern = preg_quote($wUrl, '/'); $pattern = str_replace('\*', …
Tag: php-recipes
Today’s recipes is all about to get very basic information about your visitor’s IP address location. Unfortunately, in Google App Engine, PHP GeoIP extension is not enabled in their standard environment. So sometimes, it’s essential for application developer to get the visitor’s IP address location. Here, you can easily get user’s IP address location with 3 information easily and by default from Google App Engine. In GAE, if you will discover that Google app engine itself added few extra _X_headers …
Object Oriented Programming in PHP is MUST to be a PHP programmer. See the following simple OOP Snippet written in PHP <?php /** * @author Shaharia Azam * @link http://www.shahariaazam.com * @description This simple class will return your next number. In this example the myNextNumber method will * return yourGivenNumber + 2. Because in class constructor you declared each time you will run myNextNumber method * it will return with +2. This is just for a simple OOP snippet to …