Get the MySQL server version in PHP

Description

The following code shows how to get the MySQL server version.

Example


  /*from  w w w  .j  a  va  2  s . c  om*/
<?php
     $con=mysqli_connect("localhost","root","","test");
     // Check connection
     if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
   
     echo mysqli_get_server_info($con);
    
     mysqli_close($con);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented