What is the SQL command to show all databases in a MySQL server using PHP?

To show all databases in a MySQL server using PHP, you can use the following SQL command: ```sql SHOW DATABASES; ``` To execute this SQL command in PHP, you can use the mysqli extension. Below is a PHP code snippet that connects to a MySQL server and retrieves a list of all databases:

<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Execute SQL command to show all databases
$sql = "SHOW DATABASES";
$result = $conn->query($sql);

// Output the list of databases
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo $row["Database"] . "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();
?>