I currently need to use a similar piece of PHP code. Modifying this code is not an option.
<?
session_start();
include '../connection.inc';
$conn = new Connection();
echo "ID:" . $conn->generateID();
echo "\n";
?>
In connection.inc a connection to a database can be made by creating a new Connection(). From there, the database can generate a unique 16-character ID (conn->generateID). Is there a way to retrieve to execute this PHP-file from javascript and extract the 16-character ID from the PHP-echo in javascript?
AJAXcall is your most viable solution. Though, why don't you just 'include' this file where you need it and use the variable yourself? Oh wait, because you don't want the echo to show up, right?