MySQLi - SSL Set
语法
bool mysqli_ssl_set ( mysqli $link , string $key , string $cert , string $ca , string $capath , string $cipher )
定义和用法
它用于使用 SSL 建立安全连接
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $con = mysqli_init(); if (!$con){ die("mysqli_init failed"); } mysqli_ssl_set($con,"key.pem","cert.pem","cacert.pem",NULL,NULL); $conn = new mysqli($servername, $username, $password, $dbname); if (!$conn->real_connect($con,$servername, $username, $password, $dbname)) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); } echo "Database connected"; printf("Client version: %d ", mysqli_get_client_version()); mysqli_close($con); ?>
上述代码的示例输出应该是这样的 −
Database connected Client version: 50011