The efficiency of polyaniline (PANI) coated gold wire as a fiber of solid-phase microextraction (SPME) was investigated for the extraction of phenol and 4-chlorophenol from gaseous samples and headspace of aqueous samples. Polymerization and extraction time, sample humidity, temperature, salt addition, sample pH and stirring speed were optimized. Extraction at room temperature for 80 min in the presence of 8 g NaCl at constant stirring speed yields maximum efficiency. Using the proposed microsolid phase as an efficient sampling device and capillary gas chromatography with flame ionization detection, reliable determination of these compounds at parts-per-billion and parts-per-million concentrations was achieved for the extraction from gaseous samples and headspace (HS) of aqueous samples, respectively. The calibration graphs were linear for both methods. The proposed method was successfully applied to the determination of phenol and 4-chlorophenol in real sample such as petrochemical sewage.