此函數(shù)是該函數(shù)的別名: mysqli::__construct()
雖然說在 mysqli::__construct() 的文檔 對(duì) mysqli_connect() 函數(shù)也進(jìn)行了詳細(xì)的說明, 這里依然給出一個(gè)簡(jiǎn)單的示例:
示例 #1 mysqli_connect() 例程
<?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