There is just a grain of truth in the idea, as green plants do absorb some oxygen for use in respiration, the mirror image of photosynthesis.
Photosynthesis can occur only when there is light, so at night plants are absorbers of oxygen, on balance.
However, true danger would result only from an extremely large body of plants in a very tightly closed sleeping chamber with a very limited supply of oxygen.
Another person in a room would be a far heavier oxygen consumer than one plant.
These principles of gas exchange in photosynthesis and respiration were explored in the late eighteenth century by Jan Ingenhousz, a Dutch botanist.
Once Joseph Priestley had discovered oxygen and plants’ role in producing it from carbon dioxide, there was a great vogue for putting flowers in sickrooms to “purify” the air.
Ingenhousz was skeptical about the benefits.
His experiments showed that only the green parts of plants add oxygen, and then only if placed in strong light; flowers and other non-green parts, as well as green leaves left in darkness, used up oxygen just as animals did, he found.
In aerobic respiration, plants use free oxygen, usually from the air, for chemical reactions that release energy from organic substances; sugar and oxygen react to produce carbon dioxide, water and chemical energy.
In photosynthesis, carbon dioxide and water react in the presence of light energy to produce sugar and oxygen.
During the day, both processes occur, but photosynthesis proceeds more rapidly than respiration, and the carbon dioxide produced is immediately used in photosynthesis.
Excess oxygen from the photosynthesis escapes into the air.
At night, however, photosynthesis ceases and respiration continues, so that green plants are absorbing oxygen and producing carbon dioxide.