I've heard this claim many times, that when the derivative of a function is $0$ everywhere in its domain, then that function is a constant function.
But what about functions like the following two:
$$f : (4,6)\cup (6,7) \to \mathbb{R}$$
$$f(x) = \begin{cases} 2, \, x \in (4,6) \\ \\ 7, \, x \in (6,7) \end{cases} $$
Here, $ f'(x) = 0, \, \forall x \in D_f$, where $D_f$ stands for domain of $f$.
I'm writing this after I read the proof of something similar to it in this question here:
If the derivative of a function is zero, is the function a constant function?