English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutorial básico PHP

Tutorial avançado PHP

PHP & MySQL

Manual de referência PHP

Uso e exemplo da função PHP mysqli_get_proto_info()

PHP MySQLi Reference Manual

A função mysqli_get_proto_info() retorna o número da versão do protocolo usado pelo MySQL

Definição e uso

mysqli_get_proto_info()A função é usada para obter informações sobre o protocolo (versão) MySQL utilizado.

Syntax

mysqli_get_proto_info($con);

Parameter

NumberParameters and descriptions
1

con(Optional)

This is an object representing the connection to the MySQL Server.

Return value

The PHP mysqli_get_proto_info() function returns an integer value that specifies the version of the MySQL protocol being used.

PHP version

This function was originally in PHP version5introduced and can be used in all higher versions.

Online example

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

Online example

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

Online example

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

Online example

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

PHP MySQLi Reference Manual