Studying compactons, solitons, solitary patterns and periodic solutions is important in nonlinear phenomena. In this paper we study nonlinear variants of the Kadomtsev–Petviashvili (KP) and the Korteweg–de Vries (KdV) equations with positive and negative exponents. The functional variable method is used to establish compactons, solitons, solitary patterns and periodic solutions for these variants. This method is a powerful tool for searching exact travelling solutions in closed form