To install PHP 7.2 on Ubuntu 23.04, follow the steps below.
Step 1 : Ensure your system is up-to-date by running:

Step 2 : Add the Repository
Since ppa:ondrej/php does not officially support non-LTS versions of Ubuntu, follow these steps:
- Add the Repository (ppa:ondrej/php):

- Open the file

- Find "lunar" and replace it with "jammy" Save the file.

Step 3 : Update Again

Step 4 : Create Pinning Preferences
Create the file /etc/apt/preferences.d/ondrejphp and add the following code:

Step 5 : Install PHP 7.2 core packages:

Step 6 : Install commonly used PHP extensions:

Explanation:
- mysql: MySQL database connectivity.
- curl: cURL library for making HTTP requests.
- json: JSON data format support.
- xsl: XSL extension for XML manipulation.
- gd: Graphics Draw (image processing).
- xml: XML support.
- zip: ZIP archive support.
- soap: Simple Object Access Protocol.
- bcmath: Arbitrary precision mathematics.
- mbstring: Multibyte string functions.
- gettext: Internationalization (i18n) and localization (l10n) support.
- imagick: ImageMagick PHP extension for image manipulation.
Step 7 : Verify that PHP 7.2 is installed successfully:

Congratulations! You have successfully installed PHP 7.2 on Ubuntu 23.04 with the necessary extensions.