Skip to content

Instantly share code, notes, and snippets.

@kiklop74
Created May 2, 2025 23:07
Show Gist options
  • Save kiklop74/c5ec7f4c2818d33f85fd827da4099731 to your computer and use it in GitHub Desktop.
Save kiklop74/c5ec7f4c2818d33f85fd827da4099731 to your computer and use it in GitHub Desktop.

PHP extraxt version

<?php

$data = php_strip_whitespace('version.php');
$code = str_ireplace(['<?php', '?>'], '', $data);
const MOODLE_INTERNAL = true;
const MATURITY_ALPHA = 50;
const MATURITY_BETA = 100;
const MATURITY_RC = 150;
const MATURITY_STABLE = 200;
$retval = 1;
try {
    eval($code);
    if (!empty($version)) {
        $floatVersion = floatval($version);
        if ($floatVersion > 0.0) {
            echo $floatVersion, PHP_EOL;
            $retval = 0;
        }
    }
} catch (Throwable $e) {
    $retval = 2;
    echo $e->getMessage(), PHP_EOL;
}
exit($retval);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment