The room temperature transport and optical properties of phosphorus-doped ZnO and (Zn,Mg)O thin films are studied. Pulsed laser deposition (PLD) has been employed to grow epitaxial and polycrystalline layers on c-plane (0001) sapphire substrate. The ZnO:P film properties show a strong dependence on the deposition ambient at different growth temperatures. The resistivity of the samples deposited in O3/O2 mixture is two orders of magnitude higher than the films grown in oxygen and O2/Ar/H2 mixture. The photoluminescence (PL) spectra of the as-deposited films are composed of both the near band-edge and broadband visible emission, which peak at 3.29 and 1.87 eV, respectively. It has been shown that growing in the O2/Ar/H2 mixture ambient significantly increases the band edge emission while inhibiting the visible emission. The opposite effect on the PL emissions is shown for the films grown in pure oxygen and O3/O2 mixture. There is an inverse correlation between the intensity of the visible broadband emission and the carrier density. The enhanced UV emission in the films grown in O2/Ar/H2 mixture may result from hydrogen passivation of the deep level emission centers. For the P-doped (Zn,Mg)O grown at 500°C, increasing the oxygen partial pressure from 20 to 200 mTorr yields a carrier type conversion from n-type to p-type without post-annealing. The films grown at 150 mTorr oxygen partial pressure are p-type and exhibit a hole concentration of 2.7 x 1016 cm-3, a mobility of 8.2 cm2/Vs and a resistivity of 35 Ω-cm. All the films exhibit good crystallinity with c-axis orientation. These results indicate the importance of oxidation conditions in realizing p-type (Zn,Mg)O:P films.