Note that you can get multiple results when executing a single query, for example:
<?php
$stmt = sqlsrv_query($conn, "use dbname; select 1");
?>
Running the same query in tsql or management studio works as expected. However, with sqlsrv_* functions, this gives you two result sets -- one for the "use" and one for the "select".
<?php
sqlsrv_next_result($stmt);
print_r(sqlsrv_fetch_array($stmt));
?>
For a complex query that begins by creating/populating temporary tables, you will need to advance the result pointer past such statements to get data from the final select statement. In older PHP versions (using FreeTDS-based mssql connectivity at least), you'd get only the last result so didn't need to take this into account.