$cmdStr = '/soft/java_env/jdk-15.0.1/bin/java -version 2>&1 &'; //1 $cmdStr_err = "/soft/java_env/jdk-15.0.1/bin/java -version";//2 exec($cmdStr,$result); var_dump($result);
2 result为空 1可以显示出内容
原因转自 https://blog.csdn.net/u011630575/article/details/52151995