Creating multisite in wordpress using php

There is a PHP function to create sites: wpmu_create_blog(). The simplest example is:

<?php 
$domain = "something.example.com";
$path = "https://wordpress.stackexchange.com/";
$title = "Look at my awesome site";
wpmu_create_blog($domain, $path, $title);

The catch here is you need to have WordPress loaded too in your PHP. If you are doing this as part of a plugin, then you’ll have no problem. But if you are doing this from an outside script, then you’ll need to manually load WordPress PHP code.

<?php
# Load WordPress barebones
define( 'WP_USE_THEMES', false );
require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

$domain = "something.example.com";
$path = "https://wordpress.stackexchange.com/";
$title = "Look at my awesome site";
wpmu_create_blog($domain, $path, $title);

I’ve omitted an security checking here which I leave to you.