mysqli_connect
mysqli_connect
(PHP 5, PHP 7)
mysqli_connect - mysqli 的别名:: __ construct()
描述
这个函数是一个别名:mysqli :: __ construct()
尽管mysqli :: __ construct()文档还包含使用 mysqli_connect()
函数的过程示例,但下面
是一个简短示例:
例子
Example #1 mysqli
_
connect() example
<?php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db"
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link
?>
上面的例子会输出:
Success: A proper connection to MySQL was made! The my_db database is great.
Host information: localhost via TCP/IP
← mysqli_client_encoding
mysqli::disable_reads_from_master →