The code-based method is a popular technique in fringe projection profilometry. However, the lens defocusing and ambient noise can cause the jump errors in the absolute phase. Furthermore, harsh measuring environments, such as global illumination, might aggravate the errors further. In this paper, a phase-based XOR coding strategy (PBXOR) is designed to settle the above problems simultaneously without additional patterns. Especially, the high-frequency characteristic of the wrapped phase is converted into a complementary pattern. By adopting a new coding method, the common low-frequency binary code is embedded with high-frequency information, which can suppress the errors caused by global illumination. Moreover, by utilizing the complementary pattern to optimize the decoding process, the defocusing errors are transferred from the edges of the coded patterns to their monochromatic regions, which are easy to eliminate. The results of the contrast experiments prove that PBXOR can effectively settle defocusing and global illumination. • The frequencies of coded patterns are increased to suppress global illumination. • The frequencies of the patterns are reduced in decoding to suppress the defocusing. • No additional auxiliary patterns are required. • The high-frequency auxiliary pattern is extracted from the wrapped phase.