This paper is concerned with the existence of time-periodic solutions to the nonlinear wave equation withyZf (x, t) on (0, p)!R under the periodic or anti-periodic boundary conditions y(0,t)ZGy(p, t), y x (0, t)ZGy x (p, t) and the time-periodic conditions y(x, tCT )Z y(x, t), y t (x, tCT )Zy t (x, t). Such a model arises from the forced vibrations of a nonhomogeneous string and the propagation of seismic waves in non-isotropic media. A main concept is the notion 'weak solution' to be given in §2. For TZ2p/k(k2R), we establish the existence of time-periodic solutions in the weak sense by investigating some important properties of the wave operator with x -dependent coefficients.