What are the advantages of using SQLite for small tests and experiments when working with PHP and SQL databases?

SQLite is a lightweight, serverless database that is easy to set up and use, making it ideal for small tests and experiments when working with PHP and SQL databases. It allows for quick prototyping and testing without the need for a separate database server. Additionally, SQLite databases are stored in a single file, simplifying data management and sharing.

// Connect to SQLite database
$database = new SQLite3('test.db');

// Create a table
$query = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)";
$database->exec($query);

// Insert data into the table
$query = "INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')";
$database->exec($query);

// Retrieve data from the table
$results = $database->query("SELECT * FROM users");
while ($row = $results->fetchArray()) {
    echo "ID: " . $row['id'] . " | Name: " . $row['name'] . " | Email: " . $row['email'] . "<br>";
}

// Close the database connection
$database->close();