The number of protons of an atom is always equal to the atomic number of the atom's element. In this case, we can assume that a phosphorus ion is simply an atom of phosphorus that is an ion, i.e., an atom with a nonzero electric charge. To refresh, there are three key subatomic particles that make up an atom: protons (which have a positive charge), neutrons (which have no electric charge), and electrons (which have a negative charge). Protons and neutrons are found bound to each other in the nucleus (an exception would be a neutral hydrogen, ¹H, atom, whose nucleus comprises only a single proton and no neutrons).
The atomic number of phosphorus is 15. Therefore, the phosphorus ion has 15 protons.
The number of neutrons in a phosphorus atom can be calculated by subtracting the atomic number from the atomic weight. The atomic weight of phosphorus is approximately 30.974 amu (the decimals come from the fact that this value is a weighted average of the masses of naturally-occurring isotopes of phosphorus). For our purposes, we can round our atomic weight to 31, which would reflect the number of protons and neutrons in a phosphorus atom. Subtracting our 15 protons from 31 gives us 16 neutrons. Since neutrons have no electric charge, their number would be the same in both a neutral atom and an ion of a particular isotope of phosphorus. Since we're presumably working with ³¹P (which is by far the most abundant isotope), we can safely say that the phosphorus ion has 16 neutrons.
Recall that protons have a positive charge, and we've just reiterated that neutrons have no electric charge. If all that made up an atom were protons and neutrons, the atom would have a net positive charge due to the protons. A neutral atom of an element, by definition, has no net charge because of the negatively-charged electrons surrounding the positively-charged nucleus. It follows, then, that in a neutral atom, the number of electrons equals the number of protons; so, in a neutral phosphorus atom, there would be 15 protons, 16 neutrons, and 15 electrons. The 15 positively-charged protons would neutralize the 15 negatively-charged electrons, resulting in a net atomic charge of 0.
In our phosphorus ion, we have a net charge of -2. That means that, given a nucleus with 15 positively-charged protons, we have an imbalance of 2 more negative charges. 15 electrons are needed to maintain an electrically neutral phosphorus atom; for each electron that is removed, the atom gains a positive charge, and for each electron that is added, the atom gains a negative charge. Since we have a -2 charge in the phosphorus ion, there must be 2 electrons in addition to the 15 electrons found in a neutral phosphorus atom, or 17 electrons in total. Therefore, the phosphorus ion has 17 electrons.
Note: A positively-charged ion is also called a cation, and a negatively charged ion is also called an anion. The charge of an ion has the general form Xⁿ⁺ or Xⁿ⁻, where X is the chemical species (such as an element), n is the magnitude of the charge, and the + or - respective denote a net positive or negative charge. In this case, one could represent the phosphorus anion as P²⁻.