<?php
// Create a new database
// Thanks to:
// https://www.tutorialspoint.com/sqlite/sqlite_php.htm
// for a starting point

// Class to open or create a DB file.  The constructor takes a db name argument
// This new class extends(uses) the standard SQLite3 libraries.
   class MyDB extends SQLite3 {
      function __construct($dbName) {
         $this->open($dbName);
      }
   }

// Check if a filename argument was passed to us.  If so do the work.
// Otherwise politely complain.
   if (isset($argv[1])) {

// Get the filename
     $name = $argv[1];

// Create a new instance of the MyDB class.  Which will open/create the new DB file
     $db = new MyDB($name);

// Check if it works by seeing if we got a database object.  No complain.
     if(!$db) {
// It did not open.  Display the error.
        echo "Could not open: " . $db->lastErrorMsg() . "\n";
// It worked.  Tell the user.
     } else {
       echo "Opened/created the  database successfully.\n";
     }

// A filename was not supplied.  Complain.
  } else {
    echo "Please enter a DB name to create.\n";
}
?>