CommonFunctions::checkForExtensions PHP Method

checkForExtensions() public static method

We need that extensions for almost everything This function will return a hard coded XML string (with headers) if the SimpleXML extension isn't loaded. Then it will terminate the script. See bug #1787137
public static checkForExtensions ( array $arrExt = [] ) : void
$arrExt array additional extensions for which a check should run
return void
    public static function checkForExtensions($arrExt = array())
    {
        if (strcasecmp(PSI_SYSTEM_CODEPAGE, "UTF-8") == 0 || strcasecmp(PSI_SYSTEM_CODEPAGE, "CP437") == 0) {
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom');
        } elseif (PSI_OS == "WINNT") {
            $arrReq = array('simplexml', 'pcre', 'xml', 'mbstring', 'dom', 'com_dotnet');
        } else {
            $arrReq = array('simplexml', 'pcre', 'xml', 'mbstring', 'dom');
        }
        $extensions = array_merge($arrExt, $arrReq);
        $text = "";
        $error = false;
        $text .= "<?xml version='1.0'?>\n";
        $text .= "<phpsysinfo>\n";
        $text .= "  <Error>\n";
        foreach ($extensions as $extension) {
            if (!extension_loaded($extension)) {
                $text .= "    <Function>checkForExtensions</Function>\n";
                $text .= "    <Message>phpSysInfo requires the " . $extension . " extension to php in order to work properly.</Message>\n";
                $error = true;
            }
        }
        $text .= "  </Error>\n";
        $text .= "</phpsysinfo>";
        if ($error) {
            header("Content-Type: text/xml\n\n");
            echo $text;
            die;
        }
    }

Usage Example

 /**
  * call the parent constructor and check for needed extensions
  */
 public function __construct()
 {
     CommonFunctions::checkForSVN();
     CommonFunctions::checkForExtensions();
     $this->error = Error::singleton();
     $this->_checkConfig();
 }
All Usage Examples Of CommonFunctions::checkForExtensions