How to enable Oracle Connection to PHP on XAMPP (on Windows)

1. Install XAMPP on your Windows machine. We were using the latest one v5.6.14 (you can download the same from here) on Windows XP.

2. Extract InstantClient to C:\instantclient_<version_no> folder (You can download the same from here)

3. Open system setting at Start Menu > My Computer (right click on the icon) > Select Properties > Advanced Tabs > Environment Variables.

4. Add to ‘System Variables’ by clicking ‘New’ button and insert the following values:

a. Variable Name : PATH

b. Variable Value : C:\instantclient_<version_no>

5. Click OK to accept new modification.

6. Open C:\xampp\php\php.ini by using notepad/any other text editor.

7. Find string oci8 and remove the ; symbol at the beginning of the string line.

8. Save and Exit.

9. Restart Apache server to accept new modification on xampp.


To Check if Oracle connection support is loaded or not-

1. Open web browser.

2. In the address section type http://localhost/xampp

3. Once page load, select phpinfo() menu from the link on the left section of the page.

4. Try to find string OCI8 by using the search function of your browser(or by using CTRL+F).

5. If there is string found on OCI in your phpinfo() page. Then you can start connection to your oracle database.


PHP code to connect to Oracle

1. Open notepad/your text editor

2. Type following code:



If (!conn)

  echo “Failed to connect to Oracle”;


  echo “Succesfully connected with Oracle DB”;


3. Save and exit the text files as : connection.php(All Files Category) at C:\xampp\htdocs\

4. Once saved, please open browser and enter URL http://localhost/connection.php

5. If you see Text stating “Successfully connected with Oracle DB“ , then you are good to go.


Ref: stackoverflow