All-optical photonic integrated devices have gained great attention in the field of optical computing and large-scale integration. All-optical logic gates are useful for optical signal processing and optical communication network. The flexible devices presented here satisfy the functionality of NAND (NOT-AND), NOR (NOT-OR), and XNOR (exclusive NOR) logic gates using only one structure with proper changes in the phase of an applied light signal. The design of all-optical logic gates is implemented with photonic crystal waveguides using square lattice silicon rods. The performance of the structure is simulated, verified, and analyzed by the finite-difference time-domain method, with the principle of interference effect at a wavelength of 1550 nm. The contrast ratio (CR) of NAND, NOR, and XNOR logic gates is 17.59, 14.3, and 10.52 dB, respectively, with an optimized size of 7.2 μm × 5.4 μm.