以下是提取主版本号和次版本号的方法
<?php
$link = oci_new_connect($username, $password, $server, "AL32UTF8");
$server_info = oci_server_version($link);
$version = preg_replace('~^.* (\d+\.\d+)\.\d+\.\d+\.\d+.*~s', '\1', $server_info);
echo "$server_info<br>";
// Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
echo "$version<br>";
// 11.2
?>
以下是通过 SQL 查询版本的方法
https://www.oracle.com/pls/topic/lookup?ctx=db122&id=ADMIN11039
SELECT * FROM PRODUCT_COMPONENT_VERSION;
PRODUCT VERSION STATUS
---------------------------------------- ----------- -----------
NLSRTL 12.1.0.0.1 Production
Oracle Database 12c Enterprise Edition 12.1.0.0.1 Production
PL/SQL 12.1.0.0.1 Production
?>