On the $p$th variation of a class of fractal functions