Skip to content

Instantly share code, notes, and snippets.

@SpekkoRice
SpekkoRice / checkPHPVersion
Last active July 21, 2020 07:40
Bash: Check the version of PHP
#!/bin/bash
# Function to check if the PHP version is valid
checkPHPVersion() {
# The current PHP Version of the machine
PHPVersion=$(php -v|grep --only-matching --perl-regexp "5\.\\d+\.\\d+");
# Truncate the string abit so we can do a binary comparison
currentVersion=${PHPVersion::0-2};
# The version to validate against
minimumRequiredVersion=$1;