Photo diodes are made of silicon and germanium. They have a PN associated special structure.
Principle of work
When voltage is applied across the photodiode at inverse bias, electrons move towards the positive terminal of the applied voltage and holes move towards the negative terminal of the applied voltage. This generates a tiny opposite direction current. Now if light falls on the PN surface, free current carriers break from the surface and the moving charge carriers increase. As a result; the opposite current increases.
We conclude that the opposite direction current of a photodiode is controlled by light. If the photodiode is exposed to more light, opposite direction current increases, and vice versa
Photodiodes are preferred because they are safe and sensitive to light.