Dividing a polynomial $p(x)$ by $x-k$, but $x-k$ is set to be $0$? While studying, I read the following, 

When a polynomial $p(x)$ is divided by $(x-k)$, if we set $(x-k)$ to be $0$, we get $x=k$ and the remainder as $p(k)$.

However, if we divide $p(x)$ by $(x-k)$, or $0$, wouldn't the answer be undefined?
 A: Given a polynomial $p(x)$, one can phrase the fact (coming from the division algorithm) that
$$p(x)=(x-k)\cdot q(x)+p(k)\quad$$
for some polynomial $q(x)$ as either


*

*dividing $p(x)$ by $x-k$ leaves a remainder of $p(k)$

*in the ring of polynomials $F[x]$, if we "set $x-k$ equal to $0$", i.e., quotient by the ideal $(x-k)$ to produce the ring $F[x]/(x-k)$, then we have $p(x)\equiv p(k)\bmod (x-k)$.
You're just mixing up these two phrasings of the same mathematics.
A: The "Remainder Theorem" says if you divide $p(x)$ by $(x-k)$, the remainder is equal to $p(k)$.  This follows since upon division, one obtains $p(x)=(x-k)q(x)+r$ (note the remainder is of lower degree than the divisor, and hence in this case constant).  
From this you get $p(k)=(k-k)q(k)+r=r$.
A: The division there isn't for integers but for polynomials. If for integers, the Euclidian Division states that $$\forall a,b\in\mathbb{Z},\,\exists ! \,q,r\in\mathbb{Z},\,a=bq+r\,\,\land\,\, 0\le r<|b|$$ its version for polynomials is $$\forall P,T\in\mathbb{C}[X],\,\exists !\,Q,R\in\mathbb{C}[X],\,P=TQ+R\,\,\land\,\, \deg{R}<\deg{T}$$ where $\mathbb{C}[X]$ is the set of all polynomials with complex coefficients (this set contains the set of all polynomials with real coefficients $\mathbb{R}[X]$ since $\mathbb{R}\subset\mathbb{C}$)
So in your case:$$\exists !\, Q,R\in\mathbb{C}[X],\,p(x)=(x-k)Q(x)+R(x)\,\,\land\,\,\deg{R}<\deg{(X-k)}=1$$
Since $\deg{R}<1$ therefore $R=c$ is constant and is equal to the number $c\in\mathbb{C}$ that can be $0$ or not $0$. To find it, replace $x$ by $k$ to get $p(k)=R(k)=c$ so the remainder is $p(k)$.
