A police officer who was shot seven times while conducting a drug investigation has saluted colleagues as he left a Philadelphia hospital.