php获取服务器所有数据库的名称

时间:2016-07-06
本文章向大家介绍PHP如何获取服务器上所有数据库的名称,主要使用到PHP mysql_list_dbs()函数,需要的朋友可以参考一下本文章。

实例代码如下:

<?php

   mysql_connect("127.0.0.1","root","password");
   $dbs = mysql_list_dbs();
   echo "服务器上所有数据库名称: <br />";
   while (list($db) = mysql_fetch_row($dbs)) {
      echo "$db <br />";
   }

?>

运行结果:

服务器上所有数据库名称: 
information_schema 
myapp 
mysql 
performance_schema 
school 
test