A form of antigenic variation whereby certain bacteria can change their surface antigens to evade the adaptive immune response of their host. For example, successive generations of Salmonella bacteria can switch between two different proteins to construct their flagella. Immunoglobulins that are generated specific to one type of flagellar protein do not recognize the other type, and vice versa. Phase variation typically leads to successive waves of bacteria in the host and difficulty in eliminating the infection. The mechanism involves the inversion of segments of the bacterial genome that encode antigenic proteins, with different proteins expressed depending on the orientation of the segment relative to its promoter. Such inversions are heritable and reversible, depending on trigger stimuli encountered by successive generations.