当前位置: 首页 > 知识库问答 >
问题:

PHP8 Oracle OCI8=>致命错误:未捕获错误:调用未定义的函数oci_connect()

马泰
2023-03-14

我必须升级一个旧的运行和功能的应用程序,它使用PHP5.32bit,Apache2。2 32位,Oracle客户端11.2 32位,运行在64位Windows上(Win10用于开发,服务器用于产品)。

新的堆栈是Apache2。4 32位、PHP8 32位和完全相同的Oracle客户端11.2 32位。

当我运行webapp时,在第一次尝试DB连接时出现以下错误:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in c:\some\path\connexion_check.php:16 Stack trace: #0 {main} thrown in c:\some\path\connexion_check.php on line 16

我的安装是使用以下软件包完成的:

  • Httpd-2.4.48-win32-VS16.zip
  • php-8.0.8-Win32-vs16-x86.zip
  • php_oci8-3.0.1-8.0-ts-vs16-x86.zip
  • php-debug-pack-8.0.8-Win32-vs16-x86.zip

在我的PHP中。ini文件,我已设置

extension_dir = "ext"
extension=oci8_11g 

在这里,我使用与PHP5相同的参数。3 =

运行命令php--ri-oci8说

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 3.0.1
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Compile-time Instant Client Version => 11.2

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

一些PHPINFO(来自CLI)

phpinfo()
PHP Version => 8.0.8

System => Windows NT D20899 10.0 build 19042 (Windows 10) i586
Build Date => Jun 29 2021 15:54:30
Build System => Microsoft Windows Server 2019 Datacenter [10.0.17763]
Compiler => Visual C++ 2019
Architecture => x86
Configure Command => cscript /nologo /e:jscript configure.js  "--enable-snapshot-build" "--enable-debug-pack" "--with-pdo-oci=..\..\..\..\instantclient\sdk,shared" "--with-oci8-19=..\..\..\..\instantclient\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path =>
Loaded Configuration File => C:\www\php8\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20200930
PHP Extension => 20200930
Zend Extension => 420200930
Zend Extension Build => API420200930,TS,VS16
PHP Extension Build => API20200930,TS,VS16
Debug Build => no
Thread Safety => enabled
Thread API => Windows Threads
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports => tcp, udp, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk, zlib.*, bzip2.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

除了这个webapp,我还管理/使用其他应用/工具,这些应用/工具使用相同的InstantClient安装连接到我的Oracle DB。使用以下方式从此计算机上的DB连接正常:

  • Oracle工具

我检查了很多东西,但不知道出了什么问题。谢谢你的帮助:-)

编辑:

C:\www\php8>php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mysqlnd
oci8
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
Xdebug

共有1个答案

方昊阳
2023-03-14

见鬼,我明白了。下面是下一个会遇到同样问题的人的解释。。。

以下是有关我的设置的一些数据:

  • C:\WWW\
  • C:\WWW\Apache24
  • C:\WWW\PHP8
  • C:\WWW\PHP8\php.exe
  • C:\WWW\PHP8\php.ini
  • C:\WWW\PHP8\ext
  • C:\WWW\PHP8\extoci8_11g.dll
  • C:\WWW\MyWebApp\index.php

扩展oci8不是从phpinfo()中产生的,这似乎很奇怪。使用进程监视器,我发现OCI811g。dll到处搜索(根据PATH env.variable),但不在正确的位置。

我的PHP设置。这是:

扩展名_dir=“。\ext”

ProcMon显示C:\WWW\PHP8\ext没有被搜索到,而是C:\WWW\Apache24\ext。

因此,我理解文件夹。\ext是相对于从C:\WWW\Apache24\bin运行的Apachehttpd.exe进程而言的

所以,在我的PHP中。ini文件我将我的值更改为绝对路径,以便它与CLI环境以及从Apache启动的PHP兼容。

extension\u dir=“c:\www\php8\ext”

重新启动Apache服务后,一切正常。

 类似资料: