Connect PHP 8 with Oracle 19C on CentOS

Connect PHP 8 with Oracle 19C on CentOS

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 connection
if (!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";
}
?>

Add a Comment

Your email address will not be published. Required fields are marked *