Use PHP_VERSION for the running version string and version_compare() when behavior depends on a minimum version. Avoid numeric or string comparisons that do not understand semantic version ordering.
<?php
echo PHP_VERSION . PHP_EOL;
if (version_compare(PHP_VERSION, '8.2.0', '>=')) {
echo 'PHP 8.2 or newer';
}
<?Php
echo PHP_VERSION;
?>
Output ( may change based on your PHP version )
5.6.15
echo phpversion();
Output
5.6.15
version_compare(version1,version2,operator)
It returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
echo 'I am at lower PHP version 5.3.0, my version: ' . PHP_VERSION;
}
Output
I am at lower PHP version 5.3.0, my version: 5.6.15
How to know MySQL Version?
how to check mysql support in php by using phpinfo
how to check MSSQL support in php by using phpinfo
how to check GD Support in php by using phpinfo
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| admin | 23-12-2009 |
| this site is nice | |
| murugan | 18-02-2010 |
| i like php | |
| varunkumar | 03-04-2010 |
| I love plus2net.... This help me lot... | |
| Techie Talks | 27-07-2010 |
| You can always use which displays a more detailed information about your PHP. | |
| Yogesh | 11-05-2012 |
| I like php plus2net lot of examle | |