Avoid Too Much Complexity to the Code, Instead of Returning Often and Early.

Code readability is really important part of programming. The readable and cleaner code is easily manageable and customizable. The programmer doesn’t take it seriously but it’ important. Actually, this is always an ongoing debate, but returning often, and returning early certainly make your code much cleaner looking and readable.

Understanding of PHP Traits

As we know PHP is a single inheritance language, so what does it mean? It means one class can only inherit from another one class. So it doesn’t allow to inheriting from multiple class. But sometimes it’s might be beneficial to inherit from multiple classes. To take care of this problem PHP introduced Traits in

Return Image as response by PHP

To return an image as a request response by PHP you fpassthru function of PHP. I have included a sample code snippet, which will help you to understand how to do this. From the above code snippet, you can see I have opened an image with binary mode by fopen($image, ‘rb‘). And then send that with appropriate headers by header(“Content-Type: image/png”).