In this paper,we use an invariant set to construct exact solutions to a nonlinear wave equation with a variable wave speed. Moreover,we obtain conditions under which the equation admits a nonclassical symmetry. Several different nonclassical symmetries for equations with different diffusion terms are presented.