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