下面是一個簡單的示例,展示瞭如何使用 apache_get_version() 函式:
// 獲取 Apache 伺服器的版本號
$apacheVersion = apache_get_version();
echo "Apache Version: " . $apacheVersion;
在這個示例中,我們使用 apache_get_version() 函式來獲取當前執行的 Apache 伺服器的版本號,並將其儲存在 $apacheVersion 變數中。然後,我們使用 echo 語句輸出該版本號。需要注意的是,apache_get_version() 函式只在 Apache SAPI(Server API)模組下可用。如果你的程式碼在其他 Web 伺服器或命令列環境下執行,這個函式將不起作用。
此外,還有其他一些函式可以獲取 Apache 相關資訊,例如 apache_get_modules() 可以獲取當前載入的 Apache 模組列表,apache_getenv() 可以獲取 Apache 環境變數的值等。
希望這個示例能夠幫助你理解 apache_get_version() 函式的用法和功能。