How could I connect php to SQL Server?

I’m trying to connect on windows
my php code with SQL Server(windows authentication). I am using xampp.

This is my code but it’s not working.

          $dbPassword = "";
           $dbUserName = "Inspiron/xxxxx";
           $dbServer = "localhost";
           $dbName = "person";     
//       $conn = mysqli_connect($dbServer , $dbUserName , $dbPassword,$dbName) or die("unable to connect to host"); 

       $connectionInfo = array( "Database"=>$dbName);
       $conn = sqlsrv_connect( $dbServer, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));


Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\connection\connection.php:12 Stack trace: #0 C:\xampp\htdocs\connection\phpAdd.php(2): require() #1 {main} thrown in C:\xampp\htdocs\connection\connection.php on line 12

Could someone help my or give me some links to read?

Have you installed the php drivers for sql server?

@mcalex I downloaded msodbcsql_17.3.1.1_X64.msi and SQLSRV30.

You need to install the drivers, once they’re downloaded. From that download link:

Perform the following steps to download and install the Microsoft Drivers for PHP for SQL Server (example below for 4.0 version):

  1. Download SQLSRV40.EXE to a temporary directory
  2. Run SQLSRV40.EXE
  3. When prompted, enter the path to the PHP extensions directory
  4. After extracting the files, read the Installation section of the SQLSRV_Readme.htm file for next steps