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”).


I believe you already heard about the PSR in PHP language. Today I am trying to help you to understand the what is PSR, how and why should we use it. PSR in PHP PSR knock as ‘PHP Standards Recommendation’ which is some recommendations for all PHP programmer when they write their code they should follow some

Factory Method Design Pattern in PHP

Factory method design pattern is the most common design pattern in software engineering. It’s deals with creating object of a class without specified the class name. Just simply think there is a factory of creating object of other classes. For example: We can see there is two different classes, one is Student and another is StudentFactory.  StudentFactory is

What is Anonymous Function in PHP

Anonymous is a normal PHP function but there is no specified name. Anonymous function seems like a normal/regular PHP function, it’s has a code block and run when it called, return value, it’s takes arguments as well. The major different between regular PHP function and Anonymous function are: Anonymous function doesn’t need any name to declare the function but regular PHP function must need a name to

What is PHP Magic Method, Why and How Should Use Magic Method

Magic method is called some predefined method of PHP which execute some event by the PHP compiler. The method start with the double underscore (__) known as PHP magic method (for example __construct, __destruct, __get, __set, __call etc). This is method is usually use inside any class. PHP has various magic method, I will try