//保存数据库连接信息到conn.php $fp=fopen(INSTALL_PATH.'/../conn/conn.php','w'); if (!$fp) { echo "sorry,try again!"; } $conn_config="<?php "; $conn_config.="header('Content-type: text/html; charset=UTF-8'); "; $conn_config.='$conn='; $conn_config.="mysql_connect('$tc_server','$tc_user_name','$tc_user_pass'); "; $conn_config.='$select='; $conn_config.="mysql_select_db('$tc_data_name',$conn)or die('数据库连接失败:'.mysql_error());//连接服务器 "; $conn_config.="mysql_query('set names utf8');"; $conn_config.=" ?>"; $fw=fwrite($fp,$conn_config); echo "create file end .<br/>"; if ($fw) { echo "success add conn.php !<br/>"; }else{ echo "Error!"; } fclose($fp);