var_dump保存到文本文件中 [已关闭]
我有用于sql查询的php代码
<?
$server = "127.0.0.1";
$username = "root";
$password = "1";
$link= connecttodb($server,$username,$password);
function connecttodb($server,$username,$password)
{
$rez=fopen("test.txt","ab");
if ($link=mysql_connect ("$server","$username","$password",TRUE))
{
fwrite($rez,"".$server." \r\n");
echo "Connected successfully to >> " .$server ;
$result = mysql_query('SHOW DATABASES');
echo "<br>";
while ($row = mysql_fetch_array($result))
{
var_dump ($row); }
}
}
ini_set('max_execution_time', 10);
return $link;
?>
此代码在浏览器上打印我的数据库名称如何将数据库名称保存到文本文件中
Connected successfully to >> 127.0.0.1
array(2) { [0]=> string(18) "information_schema" ["Database"]=> string(18) "information_schema" } array(2) { [0]=> string(2) "db" ["Database"]=> string(2) "db" } array(2) { [0]=> string(5) "mysql" ["Database"]=> string(5) "mysql" } array(2) { [0]=> string(10) "phpmyadmin" ["Database"]=> string(10) "phpmyadmin" } array(2) { [0]=> string(4) "test" ["Database"]=> string(4) "test" }