The correlation of subpulse phases across nulls is investigated in the radio pulsar PSR B0031−07, using 29 849 periods of high-quality data obtained with the Ooty Radio Telescope (ORT) which operates at 327 MHz. Assuming that the turn-off and turn-on subpulse phases (the phase of the subpulse in the last period before the null and that in the first period after the null, respectively) are independent random variables, the expected distribution of their difference (i.e. the total drift) is inconsistent with the observed distribution for null transitions within the same drift mode; this implies a correlation of subpulse phase across nulls. However, this correlation decreases with null duration for both the dominant drift modes. Substantial drifting occurs during short nulls (one to four periods); the drift rate during the short nulls appears to be constant for a class A transition, whereas it decreases with null duration for class B transitions. These results, together with the reported behaviour of PSR B1944+17 and PSR B0809+74, seem to imply different time-scales for phase correlation in different pulsars.