0
我的第一个功能:在另一个自定义功能的自定义函数的声明
function db_connect_error_mail ($txt) {
mail(admin_email,mail_subject01,$txt);} //1st three variables come from constants at config.php
和第2个功能:
function connectdb() {
$dbc = mysqli_connect (db_host, db_user, db_password, db_name); //variables come from constants at config.php
if (!$dbc)
{
$txt = mysqli_connect_errno().mysqli_connect_error();
db_connect_error_mail($txt);
unset ($txt);
die('custom error message to inform viewer');
} else
{
return $dbc;
}
}
我的问题:
是否好于index.php文件只需调用connectdb()?如果db连接不能设置,我会收到一封电子邮件吗? (假设服务器的邮件功能工作的所有时间)
猜,是的,只要你在'index.php'中包含'config.php'。 :) –
@Praveen库马尔:是的,我包括config.php。 –
Andre什么... ??? –