phpunit latest version code example

Example 1: how to install phpunit

# If the Suhosin extension is enabled, you need to 
# allow execution of PHARs in your php.ini:
suhosin.executor.include.whitelist = phar

# To globally install the PHAR:
$ wget https://phar.phpunit.de/phpunit-6.5.phar
$ chmod +x phpunit-6.5.phar
$ sudo mv phpunit-6.5.phar /usr/local/bin/phpunit
$ phpunit --version

# You may also use the downloaded PHAR file directly:
$ wget https://phar.phpunit.de/phpunit-6.5.phar
$ php phpunit-6.5.phar --version

Example 2: how to install phpunit

SELECT @@SERVERNAME AS 'Server Name'

Example 3: latest php version

<?php
$json = file_get_contents('https://www.php.net/releases/?json');

$releases = [];
if ($json) $releases = json_decode($json, true);

/**
 * Versions
Array
(
    [0] => 7
    [1] => 5
    [2] => 4
    [3] => 3
)
*/
$versions = array_keys($releases);

/** solution to: latest php version */
if (array_key_exists(max($versions), $releases)) {
  echo $releases[max($versions)]['version']; // as of Aug 2020.. 7.4.9
}

Tags:

Php Example