我们使用国内主流宝塔护卫神等PHP环境或虚拟主机或许不会遇到本困惑,但当前越多的人使用容器等,那么就需要我们快速对比环境差别,就用到以下PHP代码:
<style>
form{display:flex;}
textarea{flex: 5;min-width:312px; height:318px;}
</style>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$o = (isset($_POST['o']))?addslashes($_POST['o']):"o";
$n = (isset($_POST['n']))?addslashes($_POST['n']):"n";
echo '<form name="q" method="post" action="?w=fee">';
if($o!="o" && $n!="n"){
$ox = explode("\r\n", $o);
$nx = explode("\r\n", $n);
$ax = array_diff($ox, $nx);
$ay = array_diff($nx, $ox);
echo '<div><h2>本机特有</h2>';
echo "<textarea >".join("\r\n",$ax)."</textarea></div>";
echo '<div><h2>输入特有</h2>';
echo "<textarea >".join("\r\n",$ay)."</textarea></div>";
echo '<div><h2>共有扩展</h2>';
$az = array_intersect($ox,$nx);
echo "<textarea >".join("\r\n",$az)."</textarea></div>";
}else{
$dd = "Core
date
libxml
openssl
pcre
sqlite3
zlib
ctype
curl
dom
fileinfo
filter
ftp
hash
iconv
json
mbstring
SPL
PDO
pdo_sqlite
session
posix
readline
Reflection
standard
SimpleXML
Phar
tokenizer
xml
xmlreader
xmlwriter
mysqlnd
cgi-fcgi
gd
mysqli
pdo_mysql
pdo_pgsql
Zend OPcache";
$insver = get_loaded_extensions();
$jsonin = join("\r\n",$insver); //json_encode($insver,JSON_PRETTY_PRINT);
echo '<div><h2>本机扩展(PHP', PHP_VERSION, ')</h2>';
echo "<textarea name='o' placeholder=\"当前的扩展\">$jsonin</textarea></div>";
echo '<div><h2>粘贴扩展(一行一个)</h2>';
echo "<textarea name='n' placeholder=\"粘贴的扩展\">$dd</textarea></div>";
echo "<input type=\"submit\" name=\"button\" value=\"对比两者\" />";
}
echo '</form>';
?>
备注,访问文件对应网址后默认显示本机扩展和宝塔环境的扩展