Let $X$ be a topological space, $C\subseteq X$ be closed, $X\ni x\notin C$, and $f\in C(X,\mathbb R)$. Suppose further that $f(x)$ and $f(C)$ are contained in disjoint open neighborhoods of $\mathbb R$. Is this enough to enough to ensure that $x$ and $C$ are separated by a function, i.e., that there exists some $g\in C(X,\mathbb R)$ such that $g(x)=\{0\}$ and $g(C)=\{1\}$? Please give a proof or counterexample.
I'm asking because I recently looked up the definition of Tychonoff spaces and wondered if we could give an equivalent definition along the above lines.
It seems intuitively plausible to me that this is the case, but I'm guessing it's false because none of the definitions of "separation by a function" that I can find mention this.
This is a follow-up to this post, where I tried to generalize the question I'm asking here, but ended up asking the wrong thing.