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:

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?
Test your Programming skills with w3resource's quiz.
PHP: Tips of the Day
Returns all elements in an array except for the first one
Example:
<?php function tips_tail($items) { return count($items) > 1 ? array_slice($items, 1) : $items; } print_r(tips_tail([1, 5, 7])); ?>
Output:
Array ( [0] => 5 [1] => 7 )
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises