Connect PHP and SQL Server that i’m using visual studio code. using localhost and xampp as well

Where should I place my PHP file? It’s currently in a project folder.
I have downloaded the microsoft SQL Server extension in VSCode but still the undefine problem of couldn’t connect the database for running the website.
I’ve even follow the step from Utube but still there’s some errors that I may make careless but I can’t find it.


<?php

    $serverName = "localhost";
    $database = "WeighingDB";
    $uid = "sa";
    $pass = "1234567890";

    $connectionOptions = [
        "Database" => $database,
        "UID" => $uid,
        "PWD" => $pass
    ];

    $conn = sqlsrv_connect($serverName,$connectionOptions);
    if($conn == false) 
        //die(print_r(sqlsrv_errors(), true));
        echo 'failed';
    else
        echo 'Connected Successfully';
        

?>

A clear steps guiding me of connecting the PHP to the SQL Server and my other web program(htm, css, js). Connect to database