# A doubt on Gauss's law

Electric flux through a closed surface S
= q/ε0
(1.31)
q = total charge enclosed by S
In the situation when the surface is so chosen that there are some charges inside and some outside, the electric field [whose flux appears on the left side of Equation above is due to all the charges, both inside and outside S. The term q on the right side of Gauss’s law, however, represents only the total charge inside S.I want to know how that's work?