Proving that $\lim\limits_{ x \rightarrow 0}{f(g(x))}=f(\lim\limits_{ x \rightarrow 0}g(x))$ when $f$ is continuous. 
$$\lim\limits_{ x \rightarrow 0}{f(g(x))}=f(\lim\limits_{ x
 \rightarrow 0}g(x))$$

I have seen this step in a derivation of a result which is not the point of interest here.
The book wrote the reason for it was that it is when $f$ is continuous.
I wonder how one can write so. Does there exist any proof? Any hint to the proof is more appreciated.
 A: Recall the definition of limit
Let $X$ and $Y$ be metric spaces; suppose $E\subset X$, $f$ maps $E$ into $Y$, and $p$ is a limit point of $E$. We write $f(x)\rightarrow q$ as $x\rightarrow p$, or $$\lim\limits_{x\rightarrow p}{f(x)}=q$$
    if there is a point $q\in Y$ with the property: For every $\varepsilon>0$ there exists a $\delta >0$ such that $$d_{Y}(f(x),q)<\varepsilon$$ for all points $x\in E$ for which $$0<d_{X}(x,p)<\delta$$

Recall the definition of continuity.
Suppose $X$ and $Y$ are metric spaces, $E\subset X$, $p\in E$, and $f$ maps $E$ into $Y$. Then $f$ is said to be continuous at $p$ if for every $\varepsilon>0$ there exists a $\delta>0$ such that $$d_{Y}\left(f(x),f(p)\right)<\varepsilon$$ for all points $x\in E$ for which $d_{X}(x,p)<\delta$.
If $f$ is continuous at every point of $E$, then $f$ is said to be continuous on $E$.
The symbols $d_X$ an $d_Y$ refer to the distances in $X$ and $Y$ respectively.

Hint:
If $f:\mathbb{R}\rightarrow \mathbb{R}$ is continuous at $a$ if and only if $\lim\limits_{x\rightarrow a}{f(x)}=f(a)$. 
Now, assume(the existence) that $\lim\limits_{x\rightarrow 0}{g(x)}=l$ and that $f$ is continuous at $l$. Using continuity of $f$ at $l$ ....

When $\lim\limits_{x\rightarrow 0}g(x)$ does not exist, then the right hand side of the the equation becomes vague. 
On a side note, $\lim\limits_{x\rightarrow 0}{f(g(x))}$ can exist even when $\lim\limits_{x\rightarrow 0}g(x)$ doesn't. The simplest example is $f$ being a constant function and $g$ be any function discontinuous at $0$(and defined in some neighborhood of $0$).
A: Here is an $\varepsilon-\delta$ proof :
Assume that $\displaystyle \ell = \lim \limits_{x \to 0} g(x) \in \mathbb{R}$. Let $\varepsilon > 0$. The continuity of $f$ at $\ell$ writes :
$$ \exists \eta > 0, \, \forall y \in \left] \ell-\eta,\ell+\eta \right[, \; \vert f(y)-f(\ell) \vert < \varepsilon $$
and $\displaystyle \lim \limits_{x \to 0}g(x) = \ell$ writes :
$$ \exists \delta > 0, \; \forall x \in \left] -\delta,\delta \right[, \; g(x) \in \left] \ell-\eta,\ell+\eta \right[ $$
As a consequence (what we wrote previously is true for all $\varepsilon > 0$),
$$ \forall \varepsilon > 0, \; \exists \delta > 0, \; \forall x \in \left] -\delta,\delta \right[, \, \vert f(g(x)) - f(\ell) \vert < \varepsilon $$
A: If $\lim_{x \to 0} g(x)$ exists, you can pick your favorite definition of continuity and check that $\lim_{x \to 0} f(g(x))=f(\lim_{x \to 0} g(x))$.
If $\lim_{x \to 0} g(x)$ does not exist, nothing can be said in general. Assume for instance that $g$ oscillates infinitely many times between two values $a<b$ as $x \to 0$. If $f$ is a constant function, the composition $f \circ g$ converges to the value of $f$.
If $f$ is a generic continuous function, $f \circ g$ does not have, generically, a limit as $x \to 0$.
