Foam in a porous medium is a gas phase within a liquid phase, which is mainly made of thin layers. These thin layers are stabilized by surface adsorption at the gas/liquid interface. Foam injection into oil wells is an effective method to control gas-oil ratio (GOR), especially in heterogeneous and carbonate reservoirs with natural fractures that are prone to gas ingress. This method is effective because the foam can act as a barrier to gas passage and thus reduce the gas-to-oil ratio. Foam can be used to improve the condition of the production wells that have high values of gas-oil ratio (GOR) in an oil carbonate reservoir. Foam is injected through perforations that produce large amounts of gas to block the path of gas production and cause more oil to be produced from the rest of the well holes at the same time. The foam compensates for the lack of pressure near the well to calm the water and gas coning in thin oil layers, which is called anti-water and gas coning foam technology.