Although you could never tell by looking at one, every solar cell has two layers, a negative side that faces the sun, and a positive side that faces the shade. The negative and positive properties are achieved by adding impurities to the silicon from which the cell is made: phosphorus atoms on the negative side provide extra negatively charged electrons to the silicone matrix, while on the positive side, boron atoms produce positively charged holes that naturally attract wayward electrons from the negative side.
Once the two sides are mated, electrons from the negative side rush to fill the holes on the positive side, and very quickly there is a great gathering of electrons along the positive side of the border, otherwise known as the positive-negative junction. At this point however there is still no net electric charge, there are exactly as many electrons in the solar cell as there are holes, even though many of the electrons and holes have traded places.
This is where sunlight comes in. When a photon of light hits an electron on the positive side of the positive-negative junction, it imbues it with enough energy to push it back over to the negative side, where it is quickly whisked away by one of the conducting channels running through the silicon matrix and sent off to work.
The electrons mass exodus produces an electric charge in the solar cell of around 0.5 volts, and will continue to do so as long as the sun shines and the positive side is replenished with the electrons.