We perform first-principles calculations in the framework of density-functional theory to determine the effects of P doping on the electronic structure and optical properties of single-walled armchair silicon nanotubes. The calculated results indicate that the band-gap of single-walled armchair silicon nanotubes changes from indirect to direct one, with the P element doped. The top of valence band is determined mainly by the Si-3p electrons, and the bottom of conduction band is occupied by the Si-3p electrons and Si-3s electrons. Moreover, the band gap of single-walled armchair silicon nanotubes decreases and the optical absorption is red-shifted, with the P element doped. The results provide useful theoretical guidance for the applications of silicon nanotubes in optical detectors.