In this post we have explained about how to connect oracle database in PHP using XAMPP server. You need to use oci driver for oracle connection with PHP. There are two different ways to connect PHP and Oracle.

PHP and Oracle Connection in First Method:

Enable Oracle Database 12c Instant Client in php.ini file to remove semicolon

;extension=oci8_12c ; Use with Oracle Database 12c Instant Client

PHP and Oracle Connection in Second Method:

Install php_oci12 extension depends on oracle version.

Once you have complete the above process and please execute the following a sample connection program to check the oracle connectivity with PHP.

Create a file connect.php

<?php $conn=oci_connect("username","password","localhost/servicename"); If (!$conn) echo 'Failed to connect to Oracle'; else echo 'Succesfully connected with Oracle DB'; oci_close($conn); ?>

Fetch records from table

<?php $connectTbl = oci_parse($conn, 'SELECT * FROM employees'); oci_execute($connectTbl); ?>

Thanks for reading this article. If you have any queries and please comment in the below.