This is exercise 6 from Tao's notes on locally compact Hausdorff spaces. Let $X$ be such a space and assume $K \subset U$ where $K$ compact and $U$ open. We want to find a function $f:X \to \mathbb R$ with compact support and $1_K \leq f \leq 1_U$ on $X$.
As he describes, there exists an open set $V$ with $K \subset V \subset \overline V \subset U$ where $\overline V$ is compact. Now, $\overline V$ is a compact Hausdorff space and hence (Urysohn) there is a function $f:\overline V \to [0,1]$ which is $1$ on $K$ and $0$ on $\overline V \setminus V$. I thought that $f$ can be extended to $X$ by saying $f = 0$ on $X \setminus \overline V$. Is this $f$ now continuous ?
I have the following problem: If $I$ is an open subset of $\mathbb R$, then the preimage of $I$ under my extension is of the form $W \cap \overline V \cup X \setminus \overline V$ with $W$ open in $X$. The $X \setminus \overline V$ term only appears if $0 \in I$. But this union has not to be open in $X$ ?