Connect PHP 8 with Oracle 19C on CentOS
In this tutorial, we are going to see how to connect to Oracle database with PHP.

Rajan Dangi (opens in a new tab)
Senior Web Developer
1 min read

This screencast is to demonstrate the process of using Oracle 19 Instant Client, PHP8 and Oracle 19C on a Remote Machine. You can either connect to the container database or pluggable database.
Credit: Dhiraj Kumar Jha
Now, you can check the oracle database connection using this code snippet.
<?php// check oracle database connectionif (!defined("ENVIRONMENT")) define("ENVIRONMENT", "live");
$connection_string = "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 3838))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RAJAN)))";
$oraConnection = oci_connect('username', 'password', $connection_string);if (!$oraConnection) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);} else { echo "Successfully connected to Oracle";}?>Filed underWeb Developmentdatabase connectionoraclephp

Rajan Dangi
Senior Web Developer
Senior web developer at SathiSoft. I write about PHP, Python, Linux and the practical details of building for the web.
Have a project in mind? Tell us what you are building.
Start a project

