Posts marked with "Trick" in tags

Finding Exact Document Root in PHP

You might know the DOCUMENT_ROOT value of the $_SERVER array. This value indicates the absolute location of the site directory where pages are served. In short, it’s the public folder of site as defined in the server’s configuration. Here’s a quick example : If you have a site in /home/me/site and can access it by http://site.dev, then the $_SERVER[‘DOCUMENT_ROOT’] is “/home/me/site”. If any page in the server, even if it is in many sub folders, the DOCUMENT_ROOT value will be the same.... [READ MORE]

How To Set Same Cookie On Different Domains

You might have seen sites like Google setting the login status cookie on the various domains of theirs (YouTube, Blogger). As you may know, cookie can’t be set in a different domain from another domain directly. If you’re having multiple sites in where you need to set a cookie from a parent site, you can use basic **HTML **and JS to set the cookies. Google is using this same way.... [READ MORE]

Call Parent Class construct Before Child’s In PHP

If in PHP, you are making a child class of a parent class in which both have the __construct function and you want to call both of them when the child object is made, it won’t work. This is because, when you make the child class object, it’s construct function is called. The parent’s construct function is being overridden by the child. The PHP manual on OOP (Object Oriented Programming) notes this :... [READ MORE]

Add Spell Check With PHP Using Google

If you google something that has spelling mistakes, Google will automatically correct it for you or if the bot isn’t sure, it will give the Did You Mean ? clause. If you’re developing a search engine for your site, this spell check will come in handy. If the user had made a mistake and he was shown a “No Results Found” page, user will be annoyed. So, it’s better to have a spell check for your site.... [READ MORE]

Fix WordPress Database Error "MySQL server has gone away.."

If you run a WordPress blog and see the error “MySQL server has gone away for query…..” on your error logs a lot, you are certainly in trouble. When this happens, your blog will be down. It happened to this blog and I started searching for a solution. Finally I got a solution and it works. It’s a simple solution. All you have to do is add 2 lines after a specific code.... [READ MORE]

How To Use Hard Disk As RAM In Ubuntu Linux

I heard that it is possible to use a portion of hard disk as RAM in Windows. I wondered if this trick is available for Ubuntu, so I googled about it and couldn’t find anything related to it. But I found out an AskUbuntu answer of using USB sticks as RAM. I did the same trick on Hard Disk and it works !! This trick can be accomplished with the use of some small commands in Terminal.... [READ MORE]

Get Google Profile Picture URL by email id using PHP

This is a trick using Google Profile. First of all we are going to set a variable with a Google E-mail address (Gmail address). We are going to set it with my E-mail address $email=’[email protected]’;  Then we are going to split @ from the mail address. list($id, $domain) = split("@",$email); Next we are going to send a request to Google Profiles to fetch the IMAGE url. $headers = get_headers("https://profiles.google.com/s2/photos/profile/".$id, 1); The variable $id above is from the splitted part.... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab