php-mysqlHow to get the version of MySQL using PHP?
You can get the version of MySQL using PHP by using the mysqli_get_server_info()
function. This function returns a string containing the version of the MySQL server.
Example code
<?php
$conn = mysqli_connect("localhost", "username", "password", "database");
echo mysqli_get_server_info($conn);
?>
Output example
5.7.25
Code explanation
mysqli_get_server_info()
: This is the function used to get the version of MySQL.$conn
: This is the connection variable used to connect to the MySQL server.mysqli_connect()
: This is the function used to connect to the MySQL server.
Helpful links
More of Php Mysql
- How to get the first row of a result in MySQL using PHP?
- How to use utf8mb4_unicode_ci in MySQL with PHP?
- How to set a timeout for MySQL query in PHP?
- How to write an update query in MySQL using PHP?
- How to join tables with PHP and MySQL?
- How to escape a string for MySQL in PHP?
- How to generate a UUID in MySQL using PHP?
- How to use a MySQL union in PHP?
- How to check the result of an insert in PHP and MySQL?
- How to create a connection pool in a MySQL database using PHP?
See more codes...