actually it's one of the contending hypotheses for how solar panels work, there are two main contenders, the one you stated and the one I stated. neither has been definitively proven.
Solar panels aren't just randomly assembled and people pray they work. They are
engineered. We understand how they work do differently than we understand how cars work. You can say that there are two theories on how cars work, one in which gasoline is injected by a fuel pump into the pistons of an internal combustion engine and ignited, which causes the fuel to burn and expand causing the piston to rise and deliver that power to a crankshaft that turns and provides power to the drive wheels, or there's another theory where the gasoline makes the engine itch and when it tries to scratch the wheels spin. The problem is that cars are designed and constructed, not magicked together. We know what all the parts do because we put them there to do specific things. We know how solar cells work because we put all the parts there. We engineer them to capture photons of a particular energy and we know they do because we test them. We know they generate electricity due to the photovoltaic effect because we design them to do so. They create a voltage in exactly the way they are designed to do so. That voltage them induces a current in any circuit they are connected to, in exactly the same way voltages always do.
The world is an endless series of black boxes to you, Joshex, because you don't know how anything works, and you think everyone is just randomly guessing so your guess is as good as any other. But people actually know how this stuff works. It is not a guess. The "theory" of how solar cells work is not just a guess: scientific theories are not guesses. Scientific theories have to pass a huge amount of tests, have to make huge amouints of verified predictions, to become scientific theories. And how a solar panel works isn't even a scientific theory. Semiconductor physics is a set of scientific theories that have been rigorously tested. How a solar panel works is just an assemblage of those no different than the parts of a car. Solar cells are technology.
it doesn't help that you seem to have no idea whatsoever what the actual theory of photovoltaics are or how semiconductor structures work. No scientific theory says electrons get knocked out of the structure and permanently leave behind a "hole." Electrons and holes migrate under the influence of an electric field to the opposite sides of the semiconductor where the electrons on one side fill the holes on the other side. And the "holes" (they are also called phonons) aren't actually holes in the
solid structure but actually holes in the conduction band of the structure: they are a way to describe an electron state equivalent to the absence of an electron in a band of electrons. It is analogous to the hole created in traffic when a car takes the off ramp. It is not really a "thing" but it can move like a thing, at least for a while. It can be filled by another car, which creates a whole behind it. In traffic, the hole eventually closes; in semiconductors the hole persists until filled by a free electron that must obey certain rules, including overall charge neutrality.
You are why we have Science in the first place. It is so easy to simply fail to understand what the current best theories of how the universe functions are. It is so easy to convince yourself that you can do equally well or better by just randomly thinking about it in your bedroom until it sounds good in your own head. But we know that such guesses are almost always wrong. How do we expect to learn anything about the universe if every one of us is so bad at guessing how it works? Science. We demand that any guess about how the universe works be tested. We demand that any such guess make predictions about how the universe works that we can verify. We even demand that it make predictions about phenomena we haven't directly observed yet, so the guess cannot have taken them into account. We demand that these guesses explain everything we know, and also accurately predict what we don't know until we find out. When it does that enough times, we assume it is not luck, because guesses are never that lucky, and we decide to call that guess a scientific theory. Any future theory must do *better*. If it sounds good to you but it cannot do better, then we don't care.
We build theory upon theory; conjecture, verification, and acceptance, with each generation of scientists building upon the foundations of the previous one. Sometimes correcting them, but usually expanding on them. We build the structure of Science larger than any human being could construct in their lifetime, so that future generations will know more about the universe than they could possibly figure out in their lifetime. We do this with a process that reduces the likelihood that any of our guesses is fundamentally flawed. Newton built on the discoveries of others, even though his advancements were genius themselves. And the strength of Newton is that we still use Newton's laws of motion today. They were not perfect, but they agree with reality most of the time to a pretty high degree of precision. We use Einstein because his predictions are better, more accurate, and work under more conditions than Newton. But Einstein *agrees* with Newton for most common experience cases: it *has* to, because we verified Newton under those conditions already.
We didn't all just stand around and make guesses about how solar cells worked. We observed the photovoltaic effect. Einstein actually won the Nobel prize for his work on the photoelectric effect, not relativity. His theory - which was verified through experiments - laid one of the foundation stones for the quantum mechanical theory of semiconductor physics we have today. A theory that was assembled, piece by piece, through careful observation, rigorous testing of conjecture, and finally acceptance as theory. The theory *allows* us to understand how the physics works so we can build solar panels in the first place. We couldn't do that if we didn't understand how they work. Solar cells have parts, no different than the transistors and capacitors in an integrated circuit chip. Those parts all perform functions in the cell, each of which is carefully tested. Each part does what it is designed to do, or the solar cell wouldn't work. And with every solar cell we design and that then performs exactly the way we expect, the precision of the theory describing how semiconductor physics works under those conditions gets re-verified and refined.
We are at the point where we are making atomic structures in silicon that are literally only hundreds of atoms big. And we're putting that almost science-fictiony technology into basic consumer products that billions of people have. We're basically techno-mages when it comes to silicon. The fastest and densest computer chips and memory use structures so small that they operate quantum mechanically (technically, all semiconductors do, but I think the people who understand the distinction will know what I mean). There isn't even anything like "current" in them in the classical sense. Electrons behave as confined quantum entities, and we can even observe Heisenberg uncertainty messing with those devices. We design them to account for these quantum effects, but the fact that we can actually observe them and *use* them, is yet another confirmation of those quantum theories. They aren't just unobservable guesses. We don't just *think* we understand quantum mechanics: we manipulate quantum mechanics. We make quantum mechanics our bitch just so we can make better iPhones and Playstations.
None of that could happen if we were just guessing. None of that could happen if we thought they way you do, that Scientific theories are just authoritarian dictates of people who are no better than you are at figuring things out from scratch without having to verify anything.
The day the first primate picked up a rock and smashed it with another rock to make a knife, we became tool wielders. But the day two of us argued at the campfire over which kind of rock was the best one, and everyone else picked the one that seemed to cut the mastodon up quicker, that's the day we became scientists. Building upon the knowledge of our predecessors in a way that builds a solid foundation for our successors is why we aren't still arguing at that same campfire over the same rocks. It is how we get from rocks to spears to slings to wheels to pottery to writing to agriculture to iron work to steam engines to airplanes to space shuttles to the Galaxy VR. Science does that, and Science has rules. You should learn them.