  For a real analytic periodic function $\phi:\mathbb{R}\to \mathbb{R}$, an
integer $b\ge 2$ and $\lambda\in (1/b,1)$, we prove the following dichotomy for
the Weierstrass-type function $W(x)=\sum\limits_{n\ge
0}{{\lambda}^n\phi(b^nx)}$: Either $W(x)$ is real analytic, or the Hausdorff
dimension of its graph is equal to $2+\log_b\lambda$. Furthermore, given $b$
and $\phi$, the former alternative only happens for finitely many $\lambda$
unless $\phi$ is constant.
