Almost all the programs require evaluating conditions using if/else and switch/case statements. If-Else statements are easy to code and global to all languages. However, they can be too long. The ternary operator (?:) can replace a single if/else clause.
Many times, you have to programmatically resize images. Maybe you have to create multiple sizes of the same image to serve on different devices. Maybe you need to resize images that your users are uploading. You can make use of the PHP's GD library to resize images in PHP. GD has all the necessary functions to manipulate images so you won't have to use any other 3rd party library.
Websites try to format their URLs to make them easier to remember instead of depending on the file that should handle that request. Also, all the requests go through the same file, index.php, regardless of their path. Because of this, we need to keep a map of the URL paths, and who should handle them.
There are a lot of situations where you might need to get the URL of a webpage that any user might be currently visiting. For example, you may require you to dynamically generate the title of a webpage based on its URL. There are many ways in which you can obtain the URL of a webpage.
Calculating the difference between two dates is not as easy as it sounds. There are a lot of things that can go wrong if you are not careful. For example, you have to take both leap years and daylight saving time into consideration. Simply converting two dates to a timestamp and subtracting the values is not reliable in all cases. The PHP DateTime class takes care of all this.