1、https://www.microsoft.com/en-us/download/details.aspx?id=20098打开此链接,查看下面的system Requirements内容对比你所使用的php版本与操作系统。
重点关注以下内容
- Version support for PHP is as follows
- Version 4.0 supports PHP 7.0+ on Windows and Linux
- Version 3.2 supports PHP 5.6, 5.5, and 5.4 on Windows
- Version 3.1 supports PHP 5.5 and 5.4 on Windows
- Version 3.0 supports PHP 5.4 on Windows
- Version 4.0 requires Microsoft ODBC Driver 11 or Microsoft ODBC Driver 13. Version 4.0 for Linux requires Microsoft ODBC Driver 13.
- Versions 3.2 and 3.1 of the driver require Microsoft ODBC Driver 11. You can download the Microsoft ODBC Driver 11 here.
- Version 3.0 requires the x86 version of Microsoft SQL Server 2012 Native Client.
2、下载下来对应的版本后解压到文件夹下
3、在php.ini中将相应版本的加上,我用的是php5.6,所以加下如下两行
extension=php_pdo_sqlsrv_56_ts.dll
extension=php_pdo_sqlsrv_56_nts.dll
4、php信息查看显示表示php可以连接到sql server
5、再根据上面版本对应下载ODBC Driver 版本
页面错误提示如下提示时:“This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712”
6、安装完毕后连接成功
本文详细介绍如何通过正确配置PHP环境来实现与SQL Server数据库的高效连接,包括选择合适的PHP版本、下载并设置对应的ODBC Driver,以及在php.ini中进行必要的修改。
3104

被折叠的 条评论
为什么被折叠?



