Shorthand If – The Ternary Operator

You are probably already familiar with shorthand if, also known as the ternary operator. $value = get_value(); $default_value = 10; $selected_value = ($value ? $value : $default_value); If you haven’t seen shorthand if (line 3) before, it is a more elegant Read More …

Verbose If

What is wrong with this if statement? if($condition){ return true; }else{ return false; } It will work, but it is unnecessarily verbose. This way is better: return ($condition); See the difference? We just turned five lines of code into one Read More …

do{}while(0);

PHP supports many useful looping and branching structures, but sometimes a special case calls for a specialized structure Understanding do{}while(0); The do{}while(0); structure can be understood as a do{} structure. The while is set to false which will prevent it from Read More …

Is That an Upgrade or Just a Change?

Upgrade or Change? What does it take to upgrade the user interface in your application? Before you worry about this you should ask yourself what the difference is between a change and an upgrade. If the change you are making Read More …

Improving Pomodoro

Last week we discussed The Pomodoro Technique and its many benefits. If you don’t know what the Pomodoro Technique is then please read last week’s post. When I wrote last week I had used Pomodoro almost every day for months, but Read More …

The Pomodoro Technique

The Pomodoro Technique is a very simple way to boost your productivity and stay focused. It also has some hidden benefits that we will discuss. How it works Simply set a timer for 25 minutes and focus very hard during this Read More …

What’s the difference between exec(), passthru(), shell_exec(), and system()?

Did you ever wonder what the difference is between exec(), passthru(), shell_exec(), and system()? Why are there so many functions that seem to do the same thing? Let’s start by looking at what php.net has to say about them: exec Execute Read More …

Converting Sample XML to PHP DOMDocument Code

It’s time for you to build an integration and the integration partner uses a large XML document to accept data from you. They have provided a sample of the XML but no pre-built PHP code. Use this XML to PHP DOMDocument code generator Read More …

Clean URLs: An easy working sample

Clean URLs are great! They add a touch of professionalism and elegance to your website and to your code. We are going to build a barebones clean URL sample that you can use in your next project. To begin, let’s take Read More …

Building a Simple Expandable Div

An expandable div is simply a box with hidden content, but it can be revealed by clicking a button. It is great anywhere that you want lots of detailed information to be readily available but not cluttering the page. For Read More …