我在使用 XAMPP 设置服务器时遇到问题。 设置完所有内容后,PHP 抛出一个错误,指出
Call to undefined function sqlsrv_connect()
,经过更多故障排除后,我发现 PHP 找不到扩展。我的 PHP 版本是 8.0.3(顺便说一句,当我运行时 php --version
我得到了这个:
PHP Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_83_ts_x64' (tried: C:\xampp\php\ext\php_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:\xampp\php\ext\php_php_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_83_ts_x64' (tried: C:\xampp\php\ext\php_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:\xampp\php\ext\php_php_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_83_ts_x64' (tried: C:\xampp\php\ext\php_pdo_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:\xampp\php\ext\php_php_pdo_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_83_ts_x64' (tried: C:\xampp\php\ext\php_pdo_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:\xampp\php\ext\php_php_pdo_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
PHP 8.0.30 (cli) (built: Sep 1 2023 14:15:38) ( ZTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
扩展在那里:
以及在right php.ini 文件中激活:
我的分机目录:
extension_dir="C:\xampp\php\ext"
编辑:我注意到我安装了错误的模块版本,所以我将其从 83 版本更改为 80 版本。现在错误消失了,但这个错误仍然存在
Call to undefined function sqlsrv_connect()
。
有一整套问题: