You can enable the SQL Server in 4D Server to allow external connections (ODBC/SQL/PDO) connections to the 4D Server.
Once you have the SQL Server enabled then you can either use the 4D ODBC Driver on Windows/Mac or PDO_4D with PHP on Windows/Mac/Linux.
This tech tip demonstrates how to connect to 4D using PHP with both of these methods:
PDO_4D:
<?php
$dsn = '4D:host=localhost;port=19812;charset=UTF-8';
$user = 'Administrator';
$pswd = 'test';
$db = new PDO($dsn, $user, $pswd);
$db->exec('CREATE TABLE IF NOT EXISTS myTable(id INT NOT NULL, value VARCHAR(100))');
unset($db);
echo 'done'; // if you see this then the code ran successfully
?>
ODBC:
<?php
$dsn = 'dsnName'; //DSN created by the 4D ODBC driver
$user = 'username';
$pswd = 'password';
$name ='Joe';
$conn = odbc_connect($dsn,$user,$pswd);
$sql_text = "INSERT INTO Customers(Name) VALUES('".$name."')";
$sql = odbc_prepare($conn,$sql_text);
$res = odbc_execute($sql);
echo $res; // if you see this then the code ran successfully
?>
More connectivity options for 4D are listed on github here and here