English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função mysqli_get_proto_info() retorna o número da versão do protocolo usado pelo MySQL
mysqli_get_proto_info()A função é usada para obter informações sobre o protocolo (versão) MySQL utilizado.
mysqli_get_proto_info($con);
Number | Parameters and descriptions |
---|---|
1 | con(Optional) This is an object representing the connection to the MySQL Server. |
The PHP mysqli_get_proto_info() function returns an integer value that specifies the version of the MySQL protocol being used.
This function was originally in PHP version5introduced and can be used in all higher versions.
The following examples demonstratemysqli_get_proto_info()Function usage (procedural style)-
<?php //Establish connection $con = mysqli_connect("localhost","root","password","mydb"); //Protocol version $info = mysqli_get_proto_info($con); print("Protocol version: ".$info); //Close connection mysqli_close($con); ?>
Output result
Protocol version: 10
In the object-oriented style, the syntax of this function is$con-> protocol_version.The following is an example of this function in object-oriented style-
<?php //Establish connection $con = new mysqli("localhost","root","password","mydb"); //Protocol version $info = $con-> protocol_version; print("Protocol version: ".$info); //Close connection $con -> close(); ?>
Output result
Protocol version: 10
The following ismysqli_get_proto_info()Another example of the function-
<?php //Establish connection $con = mysqli_connect("localhost","root","password","mydb"); $code = mysqli_connect_errno(); if($code){ print("Connection failed: ".$code); }else{ print("Connection established successfully"."\n"); $info = mysqli_get_proto_info($con); print("Protocol version: ".$info); } ?>
Output result
Connection established successfully Protocol version: 10
Return MySQL protocol version:
<?php $con = mysqli_connect("localhost","root","password","mydb"); if (mysqli_connect_errno($con)){ echo "Unable to connect to MySQL: ".mysqli_connect_error(); } echo mysqli_get_proto_info($con); mysqli_close($con); ?>
Output result
10