w3resource
php Programming Exercies

PHP Exercises : Print current PHP version

PHP : Exercise-17 with Solution

Write a PHP script to print current PHP version.

Note : Do not use phpinfo() function.

Sample Solution: -

PHP Code:

<?php
echo 'Current PHP version : ' . phpversion();
  // prints e.g. '2.0' or nothing if the extension isn't enabled
  echo phpversion('tidy')."\n";
?>

Sample Output:

Current PHP version : 7.0.15-0ubuntu0.16.04.4 

Flowchart:

Flowchart: Print current PHP version

Note: string phpversion (string $extension ): Returns a string containing the version of the currently running PHP parser or extension.

PHP Release History:

Version Release date Supported until
1.0 8 June 1995
2.0 1 November 1997
3.0 6 June 1998 20 October 2000
4.0 22 May 2000 23 June 2001
4.1 10 December 2001 12 March 2002
4.2 22 April 2002 6 September 2002
4.3 27 December 2002 31 March 2005
4.4 11 July 2005 7 August 2008
5.0 13 July 2004 5 September 2005
5.1 24 November 2005 24 August 2006
5.2 2 November 2006 6 January 2011
5.3 30 June 2009 14 August 2014
5.4 1 March 2012 3 September 2015
5.5 20 June 2013 10 July 2016
5.6 28 August 2014 31 December 2018
6.x Not released N/A
7.0 3 December 2015 3 December 2018
7.1 1 December 2016 1 December 2019
7.2 30 November 2017 30 November 2020

Beginning on June 28, 2011, the PHP Group implemented a timeline for the release of new versions of PHP. Under this system, at least one release should occur every month. More details: http://php.net/releases/

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to count number of lines in a file.
Next: Write a PHP script to delay the program execution for the given number of seconds.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming