Phase encoding is a technique used in magnetic resonance imaging (MRI) to spatially encode signals by varying the phase of the magnetic field gradients. This allows for the reconstruction of two-dimensional or three-dimensional images by distinguishing between signals originating from different spatial locations.