How does "If $P$ then $Q$" have the same meaning as "$Q$ only if $P$ "? Every lecture that I watched on mathematical logic and my textbook say that
$P \Rightarrow Q$ has the same meaning  as $\text{"If $P$ then $Q$"}$ which has the same meaning as $\text{$Q$ only if $P$}$. 
How does " $\text{if $P$ then $Q$}$ " have the same meaning as " $\text{$Q$ only if $P$}$ 
? 
i think that is not true. For instance, let $P = \text{a human $x$ killed human $y$}$
and $Q = \text{the human $x$ will be arrested}$. 
Then $P \Rightarrow Q$ means $(\text{a human $x$ killed human $y$})  \Rightarrow (\text{the human $x$ will be arrested})$
which means
$$\text{if a human $x$ killed human $y$, then the human $x$ will be arrested} \quad (1)$$
but if we say , 
$$\text{a human $x$ will be arrested, only if the human $x$ killed human $y$} \quad (2)$$
then the meaning of (1) differs from (2). Statement (2) says that the human $x$ will be arrested in only one case which is killing $y$.
 A: I think you're mixing up the difference between:


*

*$p\;$ if $\;q$, which IS translated $q\rightarrow p$, (and is equivalent to $q \rightarrow p\;$, versus

*$p\;$ only if $\;q,\;$ which is translated $p \rightarrow q \;\equiv\;$ "if $p$ then $q$".


They are completely different statements, as "only if" $\;\not\equiv\;$ "if".
The "only if" is a "cue" that $q$ is a necessary condition for $p$.
When only "if" appears, as in "$p$ if $q$", then the "if," alone, is a cue that $q$ is a sufficient condition for $p$
$$\text{(Sufficient condition)}\quad \rightarrow \quad \text{(Necessary condition)}$$
See also this thread and the corresponding answers which is consistent with the logical translations of many sorts of "if $p$ then $q$" statements, as Zev cites, and there's some scattered explanations as to "why" these are logically equivalent statements.
Also, search math.se for "material implication" and/or "if...then...". This material implication is perhaps one of the most confusing or unintuitive of the basic logical connectives students encounter.
A: It does not have the same meaning and any texts that say that they do (which I doubt there are many of; more likely you are misinterpreting) are wrong.
$(P\implies Q)$ has the truth table
$$\begin{array}{c|c|c|}
 & P=T & P=F\\\hline
Q=T & T & T\\\hline
Q=F & F & T\\\hline
\end{array}$$
whereas "$Q$ only if $P$", i.e. $(\lnot P\implies \lnot Q)$, has truth table
$$\begin{array}{c|c|c|}
 & P=T & P=F\\\hline
Q=T & T & F\\\hline
Q=F & T & T\\\hline
\end{array}$$

Here is the relevant passage from the book you cited (p.25):

A: I lighted upon an answer by virtue of http://www.physicsforums.com/showthread.php?s=adec42ba412d779cfff53d83b02ab8c4&t=635114#post4068965.

I agree that "only if" is the most confusing of the group. I think of it this way.
Say $p \implies q$. The only way this can be false is if ♦ either p is false, ♦ or q is true.
Say p is true. If q is false that makes the implication false.
So if p is true, then q must be true.
In toto, if p => q is true, then p can be true only if q is true.
Example: Remember, if 2 + 2 = 5 then I am the Pope. That's true.
So 2 + 2 = 5 only if I am the Pope. Can't be any other way.
