There are two popular approaches to get the first element in an array. We will discuss the pros and cons of both in this article.
Category: Backend Development
Setting cookies is generally done using setcookie(), that’s a known fact. However, unsetting them generally is a bit trickier, since the cookie remains available throughout the current request, if requested via the global variable: $_COOKIE[‘the_cookie_name’] The cookie is fully removed/expired on the next page refresh. The function below will avoid this behavior. It will […]
On many occasions, you may want to check if the current visitor is browsing your site through a mobile browser. There are a lot of solutions out there (classes, libraries), but the simplest option has been working fine for me for years.
Some developers and admins complain that the new Wordpress admin bar is getting in the way. A few simple lines of code will help you get rid of it quickly.
PHPAcademy provided this wonderful 2-part tutorial on how to code a short function to check if a given website is online or down currently. Similar functionality can be seen at isup.me.
PHP arrays are cool, but if you are switching to the modern coding standards (OOP) you are probably in need of objects more often. PHP provides a very easy way to change the type of a variable from an array to an object. It’s done via typecasting. Here’s an example: ‘John’, ‘surname’=>’Walker’ ); // The […]