且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法加载动态库'C:\ xampp \ php \ ext \ php_oci8.dll'-%1不是有效的Win32应用程序

更新时间:2023-02-22 08:02:40

您的错误显示了内置类型的不匹配.

Your error shows a built-type mismatch.

请按照以下步骤解决它:

Resolve it by following these steps:

确保在以下位置下载并安装oracle instantclient :

Make sure you download and install oracle instantclient at: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:

  1. 记下您的 Oracle 数据库版本;对于Oracle数据库 12c 使用版本12.1.x ,对于 11g 版本使用版本11.1.x .
  2. 无论哪种情况,请确保下载Oracle InstantClient的 Basic Lite 版本.
  1. Take note of your Oracle database version; use Version 12.1.x for Oracle database 12c and Version 11.1.x for 11g releases.
  2. In either case, make sure you download the Basic Lite version of the Oracle instantclient.

之后,请在环境变量下的系统变量Path中添加Oracle InstantClient的位置.同样确保您同时具有 xampp 的PHP和 ext 的PHP并在其中进行设置(如果没有,请添加它们).

After that, do add location of your Oracle instantclient to your System variable Path under your Environment Variables. Do equally ensure that you have both the PHP of your xampp and its ext available and set there as well (if not, do add them).

然后,继续添加新的系统变量,并以 TNS_ADMIN 作为变量名称,并将 Oracle Instantclient的位置作为变量值.

Then, proceed to add a new System variable with TNS_ADMIN as variable name and the location to Oracle instantclient as variable value.

还要用与 value 相同的 Oracle Instantclient位置定义用户变量 PATH .

Also, define your User variables PATH with the same the location to Oracle instantclient as value.

在此阶段之后,重新启动计算机以完全传播新定义的环境变量.

After this stage, restart your computer for a full propagation of the newly defined environment variables.

一旦打开,您可以打开 Windows命令提示符并运行 where oci * ,以确保您已正确定义环境变量;响应应如下所示:

Once on, you may open your Windows Command Prompt and run where oci* to ensure that you had your environment variables well defined; the response should look like this:

C:\Users\flex>where oci*

C:\oraclexe\app\oracle\product\11.2.0\server\bin\oci.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.sym
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ociw32.dll
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym

如果没有,那么您一定错过了一些东西,需要重新访问该过程,以确保有效地完成该过程.

If not, your must have missed something and need to revisit the process, ensuring to completing it effectively.

您现在可以进入php.ini文件(提供了明确定义的环境变量),并通过取消注释来启用您的 oci 扩展名(php_oci8.dll和php_oci8_11g.dll);您只需删除上述扩展名前的半列(; )即可实现.

You may now proceed to your php.ini file (provided environment variables are well defined) and enable your oci extensions (php_oci8.dll and php_oci8_11g.dll) by uncommenting them; you can achieve that by simply removing the semi column (;) before the said extensions.

请记住保存php.ini文件,然后重新启动或启动您的Apache(如果尚未运行).

Do remember to save your php.ini file, then, restart or start your apache if it isn't already running.

要检查您的PHP oci8配置是否已启用,您可以返回Windows命令提示符并运行: php --ri oci8 ;响应应类似于以下响应:

To check your PHP oci8 configurations are enabled, you may go back to your Windows Command Prompt and run: php --ri oci8; the response should be similar to the one below:

C:\Users\flex>php --ri oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.1
Revision => $Id: 86f22a208f89dcd5b305e82929a7429683968b11 $
Oracle Run-time Client Library Version => 11.2.0.4.0
Oracle Compile-time Instant Client Version => 10.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.events => Off => Off

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

或者,您可以创建一个以<?php phpinfo(); ?>为内容的PHP文件,然后在浏览器中打开该文件并搜索oci8出现的位置.它也应该在那里显示启用.

Alternatively, you can create a PHP file with <?php phpinfo(); ?> as content, then open it in your browser and search for oci8 occurrences; it should show enabled there as well.