If a straight line $ax+by+c=0$ divides the line segment joining the points $A(x_1,y_1)$ and $B(x_2,y_2)$ in the ratio $k:1$, the standard way of finding $k$ is to use the section formula and input the point of intersection in the equation of the straight line. However, my textbook gives the following shortcut but doesn't prove it:
$$\frac{AP}{PB} = k = - \frac{ax_1+by_1+c}{ax_2+by_2+c}$$
If $k>0$, then $P$ divides $AB$ internally else externally.
Can someone please explain to me why this method works?