How To Find Version Of MySQL in PHP?

 Usually in command line we find in this way.

mysql -V

If we want to do in PHP you can do this with PDO in this way.

$db = new PDO('mysql:host=localhost', 'username', 'pass');
$version = $db->query('SHOW VARIABLES LIKE \'version\'')->fetch(PDO::FETCH_ASSOC);

echo $version['Value']; // Result: 5.7.10

If you noticed that when I making connections I did not connect any database because to learn the version you do not need to connect any database

Comments

There are no comments, make the firs comment