Tension in a string Here is the part from my book which I am referring to

A flexible weightless and in-extensible string is a constraint which prevents a body moving away, from the point of suspension of the string, in the direction of the string. The reaction of the string is directed along the string towards the point of suspension. So, string or cable can support only a tension and this force always acts in the direction of the string. The tension force developed in a continuous string,  which passes over a frictionless pulley must have a constant magnitude to keep the string in equilibrium. Hence, the string or cord, for any angle $\theta$ is subjected to a constant tension S throughout its length.


What I am unable to understand:

There is a line which says string can only support a tension, so what else could it have supported? I am unable to understand why is it necessary to have a constant magnitude of tension for any angle $\theta$ to keep the string in equilibrium. Why does this tension even have something to do with the angle?

What I know:

I know that tension arises in a string as a reaction to the weight applied by the body attached to the string. Also, we can say that each point in a string is contracted to hold the weight below it.

 A: A string cannot apply a bending force or a compression force.  Only a tension force.  That's what the phrase is meaning to convey.  
Tension can be due to any source of force, not just hanging weights.   Whatever direction the force pulls, that will be the angle of the string.  If the string in the figure is in equilibrium, then the force of tension is the same at both ends of the string regardless of the angle.  
We can generalize your last sentence:  the tension at each point in the string must be such that it balances all of the forces on either side of it.   In the case of a massless string that hangs straight down, the tension in equilibrium would equal the weight of the masses.   For a massless string at an angle, the tension would equal the applied force at the end of the string, whatever the source of that force is.    For a string with nonzero mass hanging straight down the tension at a point must support the hanging weight plus the weight of the string between the point in question and the weight.


Update:  what about a non-ideal pulley?
This takes some time to address.  The short answer:  if the pulley has friction or mass, then the tension of the left side of the string might not be the same as the tension on the right side.  Now for the long answer.

The discussion so far applies when the pulley is ideal, that is, it has neither mass nor friction.  What happens if the pulley is not ideal?  If the pulley is not ideal then we have to consider an aspect of the situation that we've so far swept under the rug:  torques on the pulley.  
Another complication arises if we allow the string to have mass.  We'll ignore that one so that we can focus on the pulley.  We will assume that the string and the pulley move together without slipping. 
There are four objects to think about.  There are two somethings that are applying forces to the ends of the string.  One of these might be a hanging mass, and if so, that side of the string will be oriented straight down.  If the other end of the string is at an angle, then the something applying the force can't be a hanging mass, it has to be something else.  Another object is the string.  The fourth is the pulley.  The string, however, has two parts: one coming off of the pulley on the left side, the other coming off of the pulley on the right side.  Each string "side" is in contact with the pulley.  The string is in tension.  Therefore, each side of the string will apply a torque to the pulley.  This is true for both the ideal pulley and the non-ideal pulley.  A non-ideal pulley will have an additional torque if there is friction in the bearing and the pulley is rotating.
The moment of inertia of the ideal pulley is zero because it has no mass.  In addition there is no torque due to friction in the bearing.  Newton's second law for the ideal pulley is $$\tau_\mathrm{net}=\tau_\mathrm{left}-\tau_\mathrm{right}=I\alpha=0$$ This means that the torque due to the left side of the string has the same magnitude as the torque due to the right part.  The pulley has just one radius, of course.  We conclude that the forces causing the torques are equal on the left and right.  The tension on the two sides of the string are the same.  This conclusion is valid regardless of the state of motion of the pulley. At rest, constant rotation rate, or changing rotation rate: the tensions on either side of an ideal pulley are the same.  This is why it's so convenient to sweep the issue under the rug.
Now if the pulley is not ideal, this conclusion is not valid.  If the pulley is not ideal the torques, and thus the tensions, do not have to be the same on the left and right.  In the case of friction, there will be an additional torque to include in the expression for net torque.  Consequently, the tensions need not be the same. (But they will be the same if the pulley is not rotating. There's no friction in that case.)  
Suppose the pulley has no friction but has mass, and a non-zero moment of inertia.  Now if $\alpha$ is zero, that is, the pulley is either not rotating or rotating at a constant rate, then the net torque is zero, and the tensions left and right are equal.  If the rotation rate of the pulley is changing, slowing down or speeding up, then $\alpha$ is not zero, and the left tension and the right tension will not be the same.
