Real Analysis question on FTC, Integral 
Let $g:[0,1] \rightarrow \mathbb R$ be a continuous function and assume that 
  $$ \int_{0}^{1} g(x) \phi'(x) dx = 0 $$
  for all continuously differentiable functions $\phi: [0,1] \rightarrow \mathbb R$, where $\phi (0) = \phi(1) = 0$. Show that $g(x) = c$ for all $x \in [0,1]$ for some constant $c \in \mathbb R$. 

My thoughts are applying integration by parts with $G(t) = \int_{0}^{t} g(x) dx $, since now we get 
$$ 0 = \int_{0}^{1} G(t) \phi'(t) dt  + \int_{0}^{1} g(t) \phi (t) dt $$ 
which doesn't really go far. The second thought was applying MVT for definite integrals, which doesn't go far either as the conditions are hardly satisfied. 
Any hints? 
 A: Hints: The conditions $\phi(0) = \phi(1) = 1$ imply
$$
\int_{0}^{1} \phi'(x)\, dx = 0;
\tag{1}
$$
that is, "the continuous function $\phi'$ is orthogonal to the constants with respect to the standard inner product in $C([0, 1])$". Consequently, the condition
$$
\int_{0}^{1} g(x) \phi'(x)\, dx = 0\quad\text{for all $C^{1}$ functions $\phi$ satisfying (1)}
\tag{2}
$$
asserts "$g$ is orthogonal to every function $\psi = \phi'$ orthogonal to the constants".
Since the inner product is non-degenerate on $C([0, 1])$, the question reduces to linear algebra.
If that's not enough, here's another hint:

 Show that if $c$ is the orthogonal projection of $g$ to the constants, then there exists a $C^{1}$ function $\phi$, vanishing at the endpoints, such that $\phi' = g - c$. Then observe that $g - c$ satisfies (2), etc.

A: We define $$c:=\int_{0}^{1}g\left(x\right)dx$$ and consider $$\phi\left(x\right)=\int_{0}^{x}\left(g\left(t\right)-c\right)dt.$$ We can see that $\phi\left(x\right)$ has the the required assumption. Now we can observe that $$\int_{0}^{1}g\left(x\right)\phi'\left(x\right)dx=0=c\int_{0}^{1}\phi'\left(x\right)dx
 $$ so we have $$\int_{0}^{1}\left(g\left(x\right)-c\right)\phi'\left(x\right)dx=\int_{0}^{1}\left(g\left(x\right)-c\right)^{2}dx=0
 $$ so it follows that $$g\equiv c
 $$ for all $x\in\left[0,1\right].$ Note that it is possible to generalize the result for every $\left[a,b\right]$.
A: Suppose $f(x)$ is not constant on $[0, 1]$. Let $m$ and $M$ be the minimum and maximum value attained by $f$ on $[0, 1]$. These values are attained on $[0, 1]$ because $f$ is continuous and $[0, 1]$ is compact. By Darboux property there exists $\gamma \in (0, 1)$ such that $f(\gamma)=\overline{f}=\frac{m+M}{2}$ and a sufficiently small $\epsilon > 0$ such that $f(x)\ge \overline{f}$ for $x \in (\gamma-\epsilon, \gamma] $ and $f(x)\le \overline{f}$ for $x \in [\gamma, \gamma + \epsilon) $(Or with the inequalities reversed). Now consider the function $$\phi(x)=\exp\left(\frac{1}{x-(\gamma+\epsilon)}-\frac{1}{x-(\gamma-\epsilon)}\right)$$ when $x \in (\gamma-\epsilon, \gamma+\epsilon)$ and $0$ otherwise. Then it is not difficult to show that $\phi(x)$ is differentiable and that $\left[\phi(\gamma-\beta)\right]_{\beta\rightarrow\epsilon}=[\phi(\gamma+\beta)]_{\beta\rightarrow\epsilon}=0$. Also, one can verify $\phi'\gt 0$ for $x \in (\gamma-\epsilon, \gamma)$ and $\phi'\lt 0$ for $x \in (\gamma, \gamma+\epsilon)$ and $0$ otherwise. From here it is trivial to see that $\int_0^1(f-\overline{f})\phi'dx>0$ which is a contradiction.
