A method based on the transport of intensity equation (TIE) for phase retrieval is presented, which can retrieve the optical phase from intensity measurements in multiple unequally-spaced planes in the near-field region. In this method, the intensity derivative in the TIE is represented by a linear combination of intensity measurements, and the coefficient of the combination can be expressed by explicitly analytical form related to the defocused distances. The proposed formula is a generalization of the TIE with high order intensity derivatives. The numerical experiments demonstrate that the proposed method can improve the accuracy of phase retrieval with higher-order intensity derivatives and is more convenient for practical application.