all elements except noble gases have less than 8 electrons in its outer shell and they are unstable.
to attain stability atoms either loses or gains or shares electrons toget 8electrons in its outer shellwhich we callit as octet rule- octa means 8..
please note first 5 elements obey duet rule and not octet rule that is having 2 electron in its outer shellthese elements are stable.
phosphorus becomes stable by either losing 5 electrons or by gaining 3 electrons andit is present in VA group of the periodic table. soits valency is either +5 or -3.