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
It seems that I am pretty late here to play with WordPress REST API. It’s really super cool! Now I can think about how well and fast I can distribute or work with wordpress blog posts. Even now you can host your whole WordPress inside a static HTML page. Funny? Yea, like your HTML page will interact with your REST API json response and small JS can help you to display inside page. Then you will get 10000000x super fast blog …
I am a big fan of PHP Slim Framework. But sometimes, I realized that when I work with large and complex libraries with Slim as dependency. It just kills my productivity, it kills my valuable time too. It’s all because of I can’t remember all the method names, properties of my dependent class or libraries. And with Pimple dependencies Slim Framework don’t have any way to bypass referencing of my third party libraries which I add through it’s container as …
Function Overloading and Overriding in PHP concept come from polymorphism of OOP. According to Object Oriented Programming, function overloading means multiple method/function have the same name but different parameters. And in the child class having the same name, same parameters as in its parent it called method overriding. Generally, PHP doesn’t support function overloading directly like other languages such as C++, JAVA etc. But we can overcome this issue with using the PHP magic method __call(). So let’s see how …
Now a days, lots of professionals are selling their creative works on ThemeForest. I just created the following simple (very simple) PHP script that works with HTML DOM and XPATH will do a very interesting job to show the ThemeForest theme information and statistics. Just run this script on your PHP environment and you will get the following information of any specific ThemeForest theme. Array ( [sellCount] => 2 [price] => $16 [created] => 2016-10-13 [lastUpdated] => 2016-10-13 [highResolution] => …